Rendering nested resources


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
the Cities of specific State as /states/1/cities, all the Streets of
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
House. In the streets#show I would like to list all the Houses and all
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
houses#show, /streets/123/houses and /streets/123/people in
etc. Without the layout.

But how?

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

Thank you for your time.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs