Forum: Ruby on Rails Rendering nested resources

Posted by unknown (Guest)
on 2013-02-26 23:29
(Received via mailing list)
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
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.