开发者

Adding collection routes to nested resources

I need to add some collection routes for a nes开发者_Python百科ted resource. I have a subscription controller and I need two new methods to add here. change_plan and update_plan

Basically I need the urls looks like;

http://localhost:3007/admin/accounts/1/subscriptions/7/change_plan
http://localhost:3007/admin/accounts/1/subscriptions/7/update_plan

So where to add change_plan and update_plan? this is what I have so far.

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

end

Thanks for any help.


Use the alternative syntax for has_many:

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜