How to convert records including 'include' associations to JSON.
Posted
by 99miles
on Stack Overflow
See other posts from Stack Overflow
or by 99miles
Published on 2010-04-02T15:59:26Z
Indexed on
2010/04/02
16:03 UTC
Read the original article
Hit count: 302
If I do something like:
result = Appointment.find( :all, :include => :staff )
logger.debug { result.inspect }
then it only prints out the Appointment data, and not the associated staff data. If I do result[0].staff.inpsect then I get the staff data of course.
The problem is I want to return this to AJAX as JSON, including the staff rows. How do I force it to include the staff rows, or do I have to loop through and create something manually?
© Stack Overflow or respective owner