Re: Nested model json

Avi
Wed, 06 Feb 2013 06:42:29 -0000

Ok found the solution:-
*respond_with(@users,  :include => {:sub_users => {:include =>
[:address]}})
*
*
*
Thanks..


On Wednesday, February 6, 2013 10:54:24 AM UTC+5:30, Avi
wrote:
>
> 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
>
>

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/AnSiEunVrzAJ.
For more options, visit https://groups.google.com/groups/opt_out.