开发者

How to create a second level route in Rails?

开发者 https://www.devze.com 2023-02-04 19:50 出处:网络
I\'m trying to get the following spec to work. So far I\'ve had some success with making both of these cases work:

I'm trying to get the following spec to work. So far I've had some success with making both of these cases work:

开发者_Go百科
  • User/Tasks -- Lists user's tasks.
  • User/Projects -- List user's projects.

But how do I get User/Project/Tasks to list all the tasks in the Project (all tasks in project, not just the user's tasks in the project)?

My routes.rb is as following:

resources :users do
  resources :tasks, :through => :projects
  resources :projects
end


Can it not simply be accomplished with?

resources :users do
  resources :projects do
    resources :tasks
  end
end

Feel free to keep the other route for :tasks around .. you'll just have to handle which case it is in your TasksController.

0

精彩评论

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