Forum: Ruby on Rails Nested model json

Posted by Avi (Guest)
on 2013-02-06 06:25
(Received via mailing list)
Hello All,

I have model relationship as :-

users has_many sub_users
sub_users has_many address

How can I do a nested json call?
I am getting sub_users value. How can I get address values through json? 
I
want all the 3 datas(users, sub_users_address at a time)

For single nested I tried - *respond_with @users.to_json(:include =>
[:sub_users])*

Thanks,
Avi
Posted by Avi (Guest)
on 2013-02-06 07:43
(Received via mailing list)
Ok found the solution:-
*respond_with(@users,  :include => {:sub_users => {:include => 
[:address]}})
*
*
*
Thanks..
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.