我試圖重定向到sign_in後的特定頁面& sign_up。我有兩個模型用戶&資源。在sign_in之後,我想顯示屬於該用戶的文檔列表。 如果沒有文件,那麼它應該重定向到users /:id/document#否則創建users /:id/document#索引。設計重定向在登錄錯誤:ActiveRecord :: RecordNotFound在DocumentsController#顯示
任何建議我該怎麼做?
我在我的控制器中定義的重定向路徑出現以下錯誤。
ActiveRecord::RecordNotFound in DocumentsController#show
Couldn't find Document without an ID
Application_controller.rb
def after_sign_in_path_for(user)
user_documents_url(user)
end
的routes.rb
root :to => 'home#index'
devise_for :users
resources :users do
resources :documents
end
devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end
路線
root / home#index
new_user_session GET /login(.:format) devise/sessions#new
user_session POST /login(.:format) devise/sessions#create
destroy_user_session DELETE /logout(.:format) devise/sessions#destroy
user_password POST /password(.:format) devise/passwords#create
new_user_password GET /password/new(.:format) devise/passwords#new
edit_user_password GET /password/edit(.:format) devise/passwords#edit
PUT /password(.:format) devise/passwords#update
cancel_user_registration GET /cancel(.:format) devise/registrations#cancel
user_registration POST / devise/registrations#create
new_user_registration GET /sign_up(.:format) devise/registrations#new
edit_user_registration GET /edit(.:format) devise/registrations#edit
PUT / devise/registrations#update
DELETE/ devise/registrations#destroy
user_confirmation POST /confirmation(.:format) devise/confirmations#create
new_user_confirmation GET /confirmation/new(.:format) devise/confirmations#new
GET /confirmation(.:format) devise/confirmations#show
user_documents POST /users/:user_id/documents(.:format) documents#create
new_user_documents GET /users/:user_id/documents/new(.:format) documents#new
edit_user_documents GET /users/:user_id/documents/edit(.:format) documents#edit
GET /users/:user_id/documents(.:format) documents#show
PUT /users/:user_id/documents(.:format) documents#update
/user/:user_id/documents(.:format) user/documents#index
謝謝
您的路線不顯示文件#索引操作。你確定你發佈了正確的routes.rb和rake路由輸出嗎? 'resources:documents'應該生成一個索引操作的路徑。 –
更新了我的路線以包含文檔#index – jsp