2014-01-31 41 views
0

路由錯誤時路由錯誤瀏覽一個實例

No route matches {:action=>"edit", :controller=>"statuses", :id=>nil} 

When http://0.0.0.0:3000/users/2 

不明白爲什麼它說:控制器=> 「狀態」當我的路由文件說:

Treebook::Application.routes.draw do 
get "users/show" 
resources :credits 
resources :merchants 
devise_for :users 
resources :statuses 
root to: 'statuses#index' 
get 'users/:id', to: 'users#show' 

耙路線

   root  /       statuses#index 
      credits GET /credits(.:format)    credits#index 
        POST /credits(.:format)    credits#create 
      new_credit GET /credits/new(.:format)   credits#new 
     edit_credit GET /credits/:id/edit(.:format) credits#edit 
       credit GET /credits/:id(.:format)   credits#show 
        PUT /credits/:id(.:format)   credits#update 
        DELETE /credits/:id(.:format)   credits#destroy 
      merchants GET /merchants(.:format)   merchants#index 
        POST /merchants(.:format)   merchants#create 
     new_merchant GET /merchants/new(.:format)  merchants#new 
     edit_merchant GET /merchants/:id/edit(.:format) merchants#edit 
      merchant GET /merchants/:id(.:format)  merchants#show 
        PUT /merchants/:id(.:format)  merchants#update 
        DELETE /merchants/:id(.:format)  merchants#destroy 
      statuses GET /statuses(.:format)   statuses#index 
        POST /statuses(.:format)   statuses#create 
      new_status GET /statuses/new(.:format)  statuses#new 
     edit_status GET /statuses/:id/edit(.:format) statuses#edit 
       status GET /statuses/:id(.:format)  statuses#show 
        PUT /statuses/:id(.:format)  statuses#update 
        DELETE /statuses/:id(.:format)  statuses#destroy 
    new_user_session GET /users/sign_in(.:format)  devise/sessions#new 
     user_session POST /users/sign_in(.:format)  devise/sessions#create 
destroy_user_session DELETE /users/sign_out(.:format)  devise/sessions#destroy 
     user_password POST /users/password(.:format)  devise/passwords#create 
    new_user_password GET /users/password/new(.:format) devise/passwords#new 
    edit_user_password GET /users/password/edit(.:format) devise/passwords#edit 
        PUT /users/password(.:format)  devise/passwords#update 

cancel_us er_registration GET /users/cancel(.:format)devise/registrations#cancel user_registration POST /users(.:format)devise/registrations#create new_user_registration GET /users/sign_up(.:format)devise/registrations#new edit_user_registration GET /users/edit(.:format)devise/registrations#edit PUT /users(.:format)devise/registrations#update DELETE /users(.:format)devise/registrations#destroy user GET/users /: (:格式)ID用戶#顯示

+0

粘貼您的整個路線文件和耙路線的輸出。這看起來不正確,你在那裏。 – rainkinz

+2

也在控制檯上做到這一點:耙路線 – khelll

+0

我會嘗試擺脫獲得「用戶/表演」的方式。這對我來說並不合適。 – rainkinz

回答

1

get "users/show" - 這很可能會造成您的問題

這裏有一個更好的途徑立案你:

root to: "statuses#index" 
resources :credits, :merchants, :statuses 

devise_for :users 
resources :users, only: [:show] 
+0

仍然沒有工作。我用耙路線更新了原始文章。 – Lut

+0

@ user1953246,你是什麼意思,它不起作用?除非您提供有用的見解,否則我們無法發佈有用的答案 – zeantsoi

+0

我得到和以前一樣的錯誤信息:沒有路由匹配{:action =>「edit」,:controller =>「statuses」,:id => nil} – Lut

0

aggggg 問題是我粘貼的一些頁腳鏈接。我剛剛刪除了兩個鏈接,因爲我不需要它們。令人難以置信的是,你的注意力如何被卡在遠離根本問題的地方。

|