开发者

Rails 3 , help with setting up a config for a controller

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜