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.
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:
Company.find(params[:id]).entries
However it only returns the entries of course. I want to is some kind of : {'id':'1', 'entries':[]}
How can I achieve this?