[英]No route matches [POST] "/sessions/user" with devise
When i try to log in using devise on my rails app, I get the following error.当我尝试在 Rails 应用程序上使用 devise 登录时,出现以下错误。
No route matches [POST] "/sessions/user"
没有路由匹配 [POST] "/sessions/user"
I have tried other solutions that I have found here but they don't seem to work.我尝试了在这里找到的其他解决方案,但它们似乎不起作用。
My routes.rb
has the following in the file.我的
routes.rb
文件中有以下内容。
Rails.application.routes.draw do
devise_for :users
resources :non_availabilities
resources :sessions
resources :programs
resources :activities
resources :locations
resources :employees
resources :expertises
resources :emp_classifications
resources :educations
get 'dashboard/index'
root 'dashboard#index'
end.
How do I fix this?我该如何解决?
您可以将此行添加到您的路线中吗
match '/sessions/user', to: 'devise/sessions#create', via: :post
I faced the exact same situation (my app has a Session
model and SessionsController
too).我面临着完全相同的情况(我的应用程序也有一个
Session
模型和SessionsController
)。 This solution worked for me, with a tiny modification. 这个解决方案对我有用,只需稍作修改。 The code below was added to
config/routes.rb
:下面的代码被添加到
config/routes.rb
:
devise_scope :user do
match '/sessions/user', to: 'devise/sessions#create', via: :post
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.