Routing nested resources in Rails 3

后端 未结 5 614
無奈伤痛
無奈伤痛 2020-12-07 20:51

I have a pretty common case for nested routes, I feel like, that looks something like this (in some sort of pseudonotation):

\'/:username/photos\' => Show         


        
5条回答
  •  北海茫月
    2020-12-07 21:26

    You could define a seperate route for getting the photos for one user like so:

    get '(:username)/photos', :to => 'photos#index'
    

    But I would advise just using the nested resource that Jimmy posted above since that is the most flexible solution.

提交回复
热议问题