I have the resource photos
Currently I have this working: /photos
which shows the photos#index controller which is what I want...
But now I want to also have /projects/2/photos
Which should show photos for that project. Problem is that is pointing to the def index, and somehow I need a s开发者_C百科eparate view for this path.
Thoughts? Thanks
routes:
resources :projects do
resources :photos,do
collection do
get 'newjs'
end
end
In the PhotosController#index
action you can check to see if params[:project_id]
is defined -- if it is then you are using the sub-resource. If it is not, you are using the top-level resource.
精彩评论