【发布时间】:2015-03-09 14:26:30
【问题描述】:
我想要这条路,我以为我可以用设计来做命名空间,但我想不通,所以我怎么能做到这一点?
users/:user_id/bills/:bills_id
我为用户设置了以下路线。
#User routes
devise_for :users, controllers: {registrations: "users/registrations", sessions: "users/sessions" }
get "/users/LeastDefender_dashboard" => "users/dashboard#index", as: :users_main
get "/users/why_choose_LeastDefender" => "users/landing#index", as: :users_why
namespace :users do
resources :landing, only: [:index, :show]
resources :bills
resources :dashboard
get 'landing', to: 'landing#index'
get 'dashboard', to: 'dashboard#index'
end
我怎样才能做到这一点?
users/:user_id/bills/:bills_id
当我搜索路线时,我得到了这个:
users_bills GET /users/bills(.:format)
users/bills#index POST /users/bills(.:format) users/bills#create
new_users_bill GET /users/bills/new(.:format) users/bills#new
edit_users_bill GET /users/bills/:id/edit(.:format) users/bills#edit
users_bill GET /users/bills/:id(.:format) users/bills#show
PATCH /users/bills/:id(.:format) users/bills#update
PUT /users/bills/:id(.:format) users/bills#update
DELETE /users/bills/:id(.:format) users/bills#destroy
【问题讨论】:
-
或者我可以得到同样的效果 /users/bills/:id 我需要账单信息是特定于每个用户的,所以当我做一个索引时它只显示用户账单。我已经拥有它还是需要指定用户?我很困惑。
标签: ruby-on-rails devise routes namespaces