Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 浏览实例时发生路由错误_Ruby On Rails_Ruby_Routes - Fatal编程技术网

Ruby on rails 浏览实例时发生路由错误

Ruby on rails 浏览实例时发生路由错误,ruby-on-rails,ruby,routes,Ruby On Rails,Ruby,Routes,路由错误 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 r

路由错误

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
取消用户注册获取/用户/取消(:格式)设计/注册取消 用户\注册帖子/用户(:格式)设计/注册\创建 新用户注册获取/用户/注册(:格式)设计/注册新 编辑用户注册获取/用户/编辑(:格式)设计/注册编辑 PUT/用户(:格式)设计/注册#更新 删除/用户(:格式)设计/注册#销毁 user GET/users/:id(:format)users#show

获取“users/show”
-这可能会导致您的问题

这里有一个更好的路由文件:

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

devise_for :users
resources :users, only: [:show]
AGGGG 问题出在我复制粘贴的一些页脚链接上。我只是删除了这两个链接,因为我不需要它们。难以置信的是,你的注意力怎么会停留在远离根本问题的地方


|粘贴整个routes文件和rake routes的输出。在控制台上也可以这样做:rake Routes顺便说一句,我会尝试摆脱get“users/show”。我觉得这不太对劲。只是在原来的问题中添加了耙路径。仍然不起作用。我用rake路由更新了原始帖子。@user1953246,你说它不工作是什么意思?除非您提供有用的见解,否则我们无法发布有用的答案。我会收到与以前相同的错误消息:没有路由匹配{:操作=>“编辑”,:控制器=>“状态”,:id=>nil}