Nested model json

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])



Ok found the solution:-

respond_with(@users, :include => {:sub_users => {:include => [:address]}})