我目前设置了默认设置,并且希望将用户ID设置在我登录的路线中,并将其他人留下,例如欢迎,常见问题,关于我们等。
如 www.example.com/ 用户ID /报价
我当前的路线档案
devise_for :users
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
resources :offers do
member do
put :tourcomplete
end
end
resources :categories, only: :show
root 'welcome#index'
get '/balance', to: 'balance#show', as: 'balance'
patch '/balance', to: 'balance#paypal', as: 'balance_paypal'
patch '/withdraw', to: 'balance#withdraw', as: 'balance_withdraw'
我无法找到任何关于此问题的文档,而我之前对类似问题的回答非常模糊且无用。
由于
答案 0 :(得分:1)
您需要使用嵌套路线:
resources :users do
resources :offers do
member do
put :tourcomplete
end
end
end
所以现在您的路线将是/users/:id/offers
,运行佣金路线来检查路线。
如果您要排除users
,则必须自行指定路线:
match ':user_id/offers' => 'offers#index'