对于询问错误Could not find devise mapping for path "/"
的人来说,有一个解决方法.
你会发现你的日志(log)中有一条线索,可能会说:
[Devise] Could not find devise mapping for path "/".
This may happen for two reasons:
1) You forgot to wrap your route inside the scope block. For example:
devise_scope :user do
match "/some/route" => "some_devise_controller"
end
2) You are testing a Devise controller bypassing the router.
If so, you can explicitly tell Devise which mapping to use:
@request.env["devise.mapping"] = Devise.mappings[:user]
因此,我try 了这种方法,但将其包装(如@miccet suggets)在一个范围块中:
devise_scope :user do
root to: "devise/sessions#new"
end
这对我很管用