导轨 2.3.11
所以我有一个命名空间,我想为它下面的每个项目指定“路径”,例如:
accounts.namespace(:accounts) do |f|
f.resources :sub_accounts, :path => "sub_accounts/:account_number/:sub_account"
end
会产生:
GET /accounts/sub_accounts/:account_number/:sub_account index
GET /accounts/sub_accounts/:account_number/:sub_account new
POST /accounts/sub_accounts/:account_number/:sub_account create
GET /accounts/sub_accounts/:account_number/:sub_account show
GET /accounts/sub_accounts/:account_number/:sub_account edit
PUT /accounts/sub_accounts/:account_number/:sub_account update
DELETE /accounts/sub_accounts/:account_number/:sub_account destroy
我知道你可以这样做:
map.connect '/accounts/sub_accounts/:account_number/:sub_account', :controller => "accounts/sub_accounts", :action => "index"
GET /accounts/sub_accounts/:account_number/:sub_account index
但是,这些变量将在帐户命名空间中的所有路由中保持一致,我不想每次都输入所有这些。有没有办法做到这一点?