在routes.rb
:
## The Humen routes by Devise
devise_for :humen, skip: [:sessions]
as :humen do
# sessions
get '/login(.:format)' => 'devise/sessions#new', as: :new_human_session
post '/login(.:format)' => 'devise/sessions#create', as: :human_session
delete 'logout' => 'devise/sessions#destroy', as: :destroy_human_session
end
然而,在转到localhost:3000/login
后,我得到了:
Routing Error
Not Found
...
new_human_session_path GET /login(.:format) devise/sessions#new
human_session_path POST /login(.:format) devise/sessions#create
destroy_human_session_path DELETE /logout(.:format) devise/sessions#destroy
哪个很糟糕。我不能为我的生活弄清楚什么是错的!
答案 0 :(得分:0)
问题中的代码发布在.
.
.
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
},
"files": [
"public/folder/"
]
},
.
.
.
文件末尾routes.rb
下方,这意味着get ':username' => 'paywall#profile'
路由在:username
之前得到解决
我将代码移到了文件的顶部,然后就可以了!
答案 1 :(得分:0)
我相信您应该将routes.rb文件中的设计路由代码更改为如下所示。
devise_scope :user do
get '/login(.:format)' => 'devise/sessions#new', as: :new_human_session
post '/login(.:format)' => 'devise/sessions#create', as: :human_session
get "logout", to: "devise/sessions#destroy", as: :logout
end