Ruby on rails 3 用宁静的用户设计
我有一个设计和用户控制器 routes.rb 用户\u controller.rb 更新:Ruby on rails 3 用宁静的用户设计,ruby-on-rails-3,rest,devise,Ruby On Rails 3,Rest,Devise,我有一个设计和用户控制器 routes.rb 用户\u controller.rb 更新: users GET /users(.:format) users#index POST /users(.:format) users#create
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#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) 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
有解决方案吗?您的routes.rb文件和生成的路由似乎不匹配。按顺序评估路由,并提供第一个匹配的路由 在自定义用户路由之前,您需要设计路由。像这样的
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) 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
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
我要确认您的routes文件与您发布的内容相似,因为它似乎不一致。您的routes.rb文件与生成的routes不匹配。按顺序评估路由,并提供第一个匹配的路由 在自定义用户路由之前,您需要设计路由。像这样的
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) 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
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
我要确认您的路由文件与您发布的文件相似,因为它看起来不一致。发生这种情况是因为您的会话被DELETE方法破坏 从您的
耙路径
:
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
当您访问http://localhost:3000/users/sign_out
,您可以使用GET
您可以在
初始化器/designe.rb
中更改方法。只需将config.sign\u out\u via
设置为:get
这是因为您的会话被DELETE方法破坏了
从您的耙路径
:
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
当您访问http://localhost:3000/users/sign_out
,您可以使用GET
您可以在
初始化器/designe.rb
中更改方法。只需将config.sign\u out\u via
设置为:获取
您看到的是路由错误,尽管您可能知道这一点。看起来它试图用用户来响应#show action,但是没有堆栈跟踪,我不能确定。尝试运行rake routes
并向我们显示处理用户的部分,这样我们就知道users/sign\u out
路由是否已映射。我不知道如何设置优先级,我将design\u for:users
移动到资源:users
下面,但这无助于您看到的是路由错误,也许你知道。看起来它试图用用户来响应#show action,但是没有堆栈跟踪,我不能确定。尝试运行rake routes
并向我们展示与用户相关的部分,这样我们就可以知道用户/注销
路由是否已映射。我不知道如何设置优先级,我将设计:用户
放在资源:用户
下面,但是它没有帮助,在中有一个简短的描述,在中有一个简短的描述
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy