Ruby on Rails Tuesday, February 26, 2013

Hello,

I have following models:

States has_many Cities
Cities has_many Streets
Streets has_many Houses
Houses has_many People

In the routes.rb I have all these set as nested resources so I can view all the Cities of specific State as /states/1/cities, all the Streets of given City as /cities/15/streets, all the Streets of specific State as /states/27/streets, etc.

Now in the houses#show action I would like to list all the People in this House. In the streets#show I would like to list all the Houses and all the People in this Street, and the same for cities#show and states#show

I would like to be DRY, so when there is a code for listing People in people#index action, I would like to somehow render /houses/1/people in the houses#show, /streets/123/houses and /streets/123/people in streets#show, etc. Without the layout.

But how?

When I call `render :template => "/houses/123/people"` the Rails throws an error that there is no such template.

Thank you for your time.
-Petr

--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/G2Rph85-WjcJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment