浏览实例时发生路由错误

时间:2014-01-31 01:55:23

标签: ruby-on-rails ruby routes

路由错误

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

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

当我的路线文件显示时,不明白为什么它会说:controller =>“状态”

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'

Rake Route

                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_user_registration GET /users/cancel(.:format)设计/注册#uncod        user_registration POST /users(.:format)设计/注册#create    new_user_registration GET /users/sign_up(.:format)设计/注册#new   edit_user_registration GET /users/edit(.:format)设计/注册#edit                          PUT /users(.:format)设计/注册#update                          删除/users(.:format)设计/注册#dutroy                     用户获取/users/:id(.:format)用户#show

2 个答案:

答案 0 :(得分:1)

get "users/show" - 这可能会导致您的问题

这是一个更好的路线文件:

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

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

答案 1 :(得分:0)

AGGGGG 问题出在我复制粘贴的一些页脚链接上。我刚刚删除了两个链接,因为我不需要它们。令人难以置信的是,你的注意力如何被卡在远离根本问题的地方。

 |