Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 向嵌套资源添加收集路由_Ruby On Rails_Routing - Fatal编程技术网

Ruby on rails 向嵌套资源添加收集路由

Ruby on rails 向嵌套资源添加收集路由,ruby-on-rails,routing,Ruby On Rails,Routing,我需要为嵌套资源添加一些收集路由。我有一个订阅控制器,我需要在这里添加两个新方法更改计划和更新计划 基本上我需要的网址看起来像 http://localhost:3007/admin/accounts/1/subscriptions/7/change_plan http://localhost:3007/admin/accounts/1/subscriptions/7/update_plan 那么在哪里添加变更计划和更新计划呢?这就是我目前所拥有的 map.namespace :admin

我需要为嵌套资源添加一些收集路由。我有一个订阅控制器,我需要在这里添加两个新方法<代码>更改计划和
更新计划

基本上我需要的网址看起来像

http://localhost:3007/admin/accounts/1/subscriptions/7/change_plan
http://localhost:3007/admin/accounts/1/subscriptions/7/update_plan
那么在哪里添加变更计划和更新计划呢?这就是我目前所拥有的

 map.namespace :admin do |admin|
    admin.resources :payments
    admin.resources :accounts, :collection=>{:profile=>:get}, :has_many => [:payments,:subscriptions]
结束


谢谢您的帮助。

使用
的替代语法有很多

admin.resources :accounts, :collection=>{:profile=>:get} do |account|
  account.resources :subscriptions, :member => { :change_plan => :get, ... }
  ...
end

使用
的替代语法有许多

admin.resources :accounts, :collection=>{:profile=>:get} do |account|
  account.resources :subscriptions, :member => { :change_plan => :get, ... }
  ...
end

这很管用,马塞尔,多谢了。我会把它标记为答案。这很有效,马塞尔,非常感谢。我将把它标为答案。