2010-07-23 63 views
1

我需要爲嵌套資源添加一些收集路徑。我有一個訂閱控制器,我需要在這裏添加兩個新的方法。 change_planupdate_plan將收集路線添加到嵌套資源

基本上我需要的網址看起來像;

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

那麼在哪裏添加change_plan和update_plan?這是迄今爲止我所擁有的。

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

感謝您的幫助。

回答

4

使用替代語法has_many

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

這工作得很好馬塞爾,感謝了一堆。我會將其標記爲答案。 – randika 2010-07-23 12:10:12