I have a rails3 application with the following structure
Users
has_many: tasks
has_many: staff
has_many: managers
Tasks
has_one: location
Locations
has_many: staff
has_one: manager
Staff
belongs_to: users
belongs_to: location
Managers
belongs_to: users
belongs_to: location
Now in my json release I am trying to get the User, their tasks, the location of each task, as well as the staff and the location manager.
I have
@User = User.find (params [: id],: include {: tasks =>: location})
This displays the user and the location of the tasks, but not the tasks themselves.
And in the future I try to add, for example, leads to an error
@User = User.find (params [: id],: include {: tasks =>: location =>: staff})
I get the error "unexpected tASSOC pending".
What is the correct way to write, so I get all related data for this user?
source share