views:

12

answers:

1

I need to add some collection routes for a nested 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.

+4  A: 

Use the alternative syntax for has_many:

admin.resources :accounts, :collection=>{:profile=>:get} do |account|
  account.resources :subscriptions, :member => { :change_plan => :get, ... }
  ...
end
Marcel J.
That worked pretty well Marcel, thanks a bunch. I'll mark it as the answer.
randika