title: Complex ActiveRecord Query with JSON in Ruby on Rails
body: <p>I have two tables which associated with each other. My first table is Company and other one is Entry. Entries has one Company and Companies has many entries. The foreign keys are entry_id and company_id.</p>
  
  <p>I'm trying to retrieve the query data as JSON in AJAX request and this is the last query that I can do so far:</p>
  
  <pre><code>Company.find(params[:id]).entries
  </code></pre>
  
  <p>However it only returns the entries of course. I want to is some kind of : {'id':'1', 'entries':[]}</p>
  
  <p>How can I achieve this?</p>