On Nov 20, 8:02 am, Tom Lobato <[EMAIL PROTECTED]> wrote:
> I have 3 tables:
> pupils:           id, name, born_date, sex
> courses:        id, course_name, description
> pupilXcourse: pupil_id, course_id
>
> Today I run a Pupil.find(:all) and send a json response to the
> browser, who shows a table of pupils and its attributes.
> I want to include in this listing on the browser a field showing what
> courses each pupil got.

If you're just using Rails' to_json and you've got the appropriate
associations then you can just do pupils.to_json :include => :courses

Fred

> I don`t know the fast/easy method to achieve this. Maybe a custom,
> more complex, select statment, or a additional select with additional
> json request.
>
> If you have hints or examples, it you be very welcome.
>
> Thank you!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to