title: saving JSON response as an object rails
body: <p>I am looking to clarify my understanding here or actually understand... I have a a JSON response like so</p>
  
  <pre><code>  {
   "resultCount":1,
    "results": [
   {"kind":"ebook", "artistId":545975179, "artistName":"Gareth Halfacree", "price":9.99, 
   "description":"&lt;p&gt;&lt;b&gt;Make the most out of the world&amp;rsquo;s first truly compact  computer&lt;\/b&gt;&lt;\/p&gt;&lt;p&gt;It's the size of a credit card, it can be charged like a smartphone,  it runs on open-source Linux, and it holds the promise of bringing programming and playing  to millions at low cost. And now you can learn how to use this amazing computer from its co-creator, Eben Upton, in &lt;i&gt;Raspberry Pi User Guide&lt;\/i&gt;. Cowritten with Gareth Halfacree, this guide gets you up and running on Raspberry Pi, whether you're an educator, hacker, hobbyist, or kid. Learn how to connect your Pi to other hardware, install software, write basic programs, and set it up to run robots, multimedia centers, and more.&lt;\/p&gt;&lt;ul&gt;&lt;li&gt;Gets you up and running on Raspberry Pi, a high-tech computer the size of a credit card &lt;\/li&gt;&lt;li&gt;Helps educators teach students how to program &lt;\/li&gt;&lt;li&gt;Covers connecting Raspberry Pi to other hardware, such as monitors and keyboards, how to install software, and how to configure Raspberry Pi &lt;\/li&gt;&lt;li&gt;Shows you how to set up Raspberry Pi as a simple productivity computer, write basic programs in Python, connect to servos and sensors, and drive a robot or multimedia center &lt;\/li&gt;&lt;\/ul&gt;&lt;p&gt;Adults, kids, and devoted hardware hackers, now that you've got a Raspberry Pi, get the very most out of it with &lt;i&gt;Raspberry Pi User Guide&lt;\/i&gt;.&lt;\/p&gt;", "genreIds":["10017", "38", "9027"], "releaseDate":"2012-08-30T07:00:00Z", "currency":"USD", "genres":["Computers", "Books", "Computers &amp; Internet"], "trackId":559783692, "trackName":"Raspberry Pi User Guide",  "artistIds":[545975179],  "artworkUrl60":"http://a2.mzstatic.com/us/r30/Publication/v4/ba/a8/2c/baa82ce0-2ac7-7026-04da-6f74bc97b403/9781118464496.60x60-50.jpg", "artistViewUrl":"https://itunes.apple.com/us/artist/gareth-halfacree/id545975179?mt=11&amp;uo=4", "trackCensoredName":"Raspberry Pi User Guide", "formattedPrice":"$9.99", "artworkUrl100":"http://a4.mzstatic.com/us/r30/Publication/v4/ba/a8/2c/baa82ce0-2ac7-7026-04da-6f74bc97b403/9781118464496.100x100-75.jpg", "trackViewUrl":"https://itunes.apple.com/us/book/raspberry-pi-user-guide/id559783692?mt=11&amp;uo=4", "averageUserRating":2.5, "userRatingCount":5}]
  </code></pre>
  
  <p>}</p>
  
  <p>and i would like to save it certain values to my book model after clicking a link_to ( i have read that link_to is more secure than say button_to)</p>
  
  <p>So i have a module that handles the parsing which is included in my controller </p>
  
  <pre><code>    module Book::BookFinder
  
  BOOK_URL = 'https://itunes.apple.com/lookup?isbn='
  
  def book_search(search)
      response = HTTParty.get(BOOK_URL + "#{search}", :headers =&gt; { 'Content-Type' =&gt; 'application/json', 'Accept' =&gt; 'application/json' })
  results = JSON.parse(response.body)["results"]
  end
      end
  </code></pre>
  
  <p>Within my books controller</p>
  
  <pre><code>class BookController &lt; ApplicationController
  before_filter :authenticate_admin_user!
  include Book::BookFinder
  
  def searchbook
  
  end
  
  def results
   results = book_search(params[:search])
   @results = results
  
  end
  
  def savebook
  
  Book.create(:author =&gt; response["results"]["artistName"])
  
  end
  end
  </code></pre>
  
  <p>(Firstly i look at this and think that using rails restful practices would be better, so using the new and create methods?)</p>
  
  <p>I have a link_to setup to post the data to my model</p>
  
  <pre><code>&lt;%= link_to 'Save Book', savebook_path,  :method =&gt; :post %&gt;
  </code></pre>
  
  <p>and my routes</p>
  
  <pre><code>scope :controller  =&gt; :book do
  get 'searchbook'
  get 'results'
  post 'savebook'
  
  end
  </code></pre>
  
  <p>So at present i get a error message when clicking the link_to, it says wrong number of arguments (0 for 1).</p>
  
  <p>because I am getting the data externally it has thrown me a little, when dealing with posting data from a form using new, create, edit etc it makes sense, but here i am a little lost</p>
  
  <p>Could anyone offer some advice/solutions to help me understand what needs to happen</p>
  
  <p>Thanks</p>