2012-05-21 260 views
1

我有以下的路徑,在我的Rails應用程序:Rails 3的路由:資源和路徑

resources :settings, :path => :account, :only => [:edit, :update] 

這將創建下列內容:

edit_setting GET /account/:id/edit(.:format) settings#edit 
setting PUT /account/:id(.:format) settings#update 

我怎樣寫它,因此:id省略?

所以用戶可以只訪問/account/edit

回答

3

這可能是最簡單的方法來做到這一點,並讓你靠近軌道約定:

match 'account/edit' => 'accounts#edit', :as => 'edit_account', :via => :get 
match 'accounts'  => 'accounts#update', :as => 'accounts',  :via => :put