title: Iterate through an array of hashes and save each hash as a record in a ruby on rails (postgresql) table
body: <p>I have successfully extracted 90 articles (their titles, links and text), now want to put this data into a table </p>
  
  <p>I created the table:</p>
  
  <pre><code>rails g model Article title:string link:string paragraphs:text
  </code></pre>
  
  <p>In the irb, I can run my extraction (using Nokogiri) to get the data and set it equal to articlesArray</p>
  
  <p>But I cannot figure out what to do next. I cannot work out the correct syntax to get the data successfully into the table</p>
  
  <p>I am still in the irb (not in rails c) - if that makes any difference</p>
  
  <p>I am really struggling</p>
  
  <p><strong>Here are a few things I've tried so far</strong></p>
  
  <pre><code>for i in 0...articlesArray.length
      Article.create(
          title: articlesArray[i].title,
          link: articlesArray[i].link,
          paragraphs: articlesArray[i].paragraphs.text[176...articlesArray[i].paragraphs.text.length-283]      
          )
  end
  </code></pre>
  
  <p>Trying another approach</p>
  
  <pre><code>for i in 0...articlesArray.length-1
  
  @article = Article.new
  
  @article.title = articlesArray[i].title
  @article.link = articlesArray[i].link
  @article.paragraphs = articlesArray[i].paragraphs.text[176...articlesArray[i].paragraphs.text.length-283] 
  
  @article.save
  end
  </code></pre>
  
  <p>And again</p>
  
  <pre><code>articlesArray.each do |article|
  
      @article = Article.new
  
      @article.title = article.title
      @article.link = article.link
      @article.paragraphs = article.paragraphs.text[176...article.paragraphs.text.length-283] 
  
      @article.save
  end
  </code></pre>
  
  <p>None of these seem to work</p>