[英]Ruby on Rails Error, Routing Error No route matches [GET] “/users”, Devise
So I added devise to my Rails project and the generated a user scaffold called, users
, after I did that I tried to enter the /users
section of my site but I can only access a few branches of it like: /users/sign_in
, /users/sign_up
, /users/edit
, etc. 因此,我增加设计到我的Rails项目,并呼吁生成的用户支架,
users
,当我这样做,我试图进入/users
我的网站的部分,但我只能访问它的几个分支,如: /users/sign_in
, /users/sign_up
, /users/edit
等。
This is the error page that I get: 这是我得到的错误页面:
[Error page]: [错误页面]:
This is my routes file: 这是我的路线文件:
Stoabook::Application.routes.draw do
devise_for :users
resources :statuses
root to: 'statuses#index'
end
And this is what I get when I run rake routes: 这是我运行耙路时得到的:
Prefix Verb URI Pattern Controller#Action
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
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_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
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#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
PATCH /statuses/:id(.:format) statuses#update
PUT /statuses/:id(.:format) statuses#update
DELETE /statuses/:id(.:format) statuses#destroy
root GET / statuses#index
I have tried restarting my server many times. 我尝试过多次重启服务器。
EDIT: 编辑:
I didn't Scaffold it. 我没有脚手架。 I used the devise helper:
我使用了设计助手:
rails generate devise user
It seems you did not actually scaffold users, but you used the devise generator. 看来您实际上并没有为用户提供支持,但是您使用了devise生成器。 That is a big difference.
那是很大的不同。 A regular scaffold generates all CRUD routes.
常规脚手架会生成所有CRUD路线。 The devise generator on the other hand does not.
另一方面,设计生成器则没有。 It is solely concerned with authentication resources, such as signing up or in.
它仅与身份验证资源有关,例如注册或登录。
If you want more routes you should generate your own users controller. 如果需要更多路由,则应生成自己的用户控制器。 This way you can overwrite or expand on what devise already provided under the hood.It is probably a wise plan to check the github page and wiki for devise.
通过这种方式,您可以覆盖或扩展已在幕后提供的设计方案。检查github页面和wiki的设计方案可能是一个明智的计划。
Ps Please try to avoid scaffolding if possible. 附言:请尽量避免使用脚手架。 Yes, it speed things up, but does so at the expanse of learning what is actually going on.
是的,它加快了速度,但是在了解实际发生的事情时才这样做。 Moreover, it usually creates more than you actually need.
而且,它通常会创建超出您实际需求的东西。 If you forget to remove unused generated code, your code becomes bloated.
如果您忘记删除未使用的生成代码,则代码会becomes肿。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.