title: Rails 3 - Creating a JSON response to display Search Results
body: <p>I'm working to have Rails 3 respond with a JSON request which will then let the app output the search results with the jQuery template plugin...</p>
  
  <p>For the plugin to work, it needs this type of structure:</p>
  
  <pre><code>[
   { title: "The Red Violin", url: "/adadad/123/ads", desc: "blah yada" },
   { title: "Eyes Wide Shut", url: "/adadad/123/ads", desc: "blah yada" },
   { title: "The Inheritance", url: "/adadad/123/ads", desc: "blah yada" }
  ]
  </code></pre>
  
  <p>In my Rails 3 controller, I'm getting the search results which come back as @searchresults, which contain either 0 , 1 , or more objects from the class searched.</p>
  
  <p>My question is how to convert that to the above structure (JSON)...</p>
  
  <p>Thank you!</p>
  
  <p><strong>Update</strong>
  Forgot to mention. The front-end search page will need to work for multiple models which have different db columns. That's why I'd like to learn how to convert that to the above to normalize the results, and send back to the user.</p>