2015-10-15 36 views
0

我現在有一個默認色器件設置,並希望把用戶ID的內我的路線記錄,並讓其他人獨自如歡迎,常見問題,關於我們等配售用戶ID與設計

這樣的作爲 www.example.com/ 用戶ID /提供

我目前的routes文件

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' 

我無法找到任何這Docs和我以前回答過類似的問題是很模糊和不沒有幫助。

感謝

回答

1

您需要使用嵌套的路線:

resources :users do 
    resources :offers do 
    member do 
     put :tourcomplete 
    end 
    end 
end 

所以現在你的路線將是/users/:id/offers,運行耙路線來檢查您的路線。

如果要排除users,那麼你必須指定自己的路線:我試圖把它的路線

match ':user_id/offers' => 'offers#index' 
+0

?不通過視圖 – Jonathan

+0

訪問它,讓我們知道爲什麼可能是它不是做你想做什麼的最佳方式。 –

+0

我試圖將User-id放入我的路線中,例如www.hello.com/user-id/offers,你的回答是描述如何把用戶id放入我的views html中。 – Jonathan