我在我的应用程序中使用设计进行身份验证。我的路线文件如下所示:
devise_scope :user do
get "/password_reset" => "devise/passwords#new", :as => "new_user_password"
post "/password_reset/complete" => "devise/passwords#create", :as => "user_password"
get "/password_renew" => "devise/passwords#edit", :as => "edit_user_password"
put "/password_renew/complete" => "devise/passwords#update", :as => "password"
end
完整的 routes.rb 文件:http ://hastebin.com/vofaluhera.coffee
运行 rake 路线表明这些路线运行良好:
new_user_password GET /password_reset(.:format) devise/passwords#new
user_password POST /password_reset/complete(.:format) devise/passwords#create
edit_user_password GET /password_renew(.:format) devise/passwords#edit
password PUT /password_renew/complete(.:format) devise/passwords#update
但是,当我访问 route /password_reset 时,它会引发此错误:
Could not find devise mapping for path "/password_reset"
此外,当我切换到 devise_for 时,它工作正常,但带有弃用警告,它添加了更多不需要的路由。所以基本上,我想坚持使用 devise_scope
请帮我解决这个错误。
编辑:原来我需要在使用 devise_scope 之前添加
devise_for :users, :skip => [:passwords]