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
这很管用,马塞尔,多谢了。我会把它标记为答案。这很有效,马塞尔,非常感谢。我将把它标为答案。