找不到路径“/”的设计映射。在用户登录之前

Could not find devise mapping for path "/". before the user has signed in

登录

后转到root时出现以下错误
    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 get "/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]

路由文件

    Rails.application.routes.draw do

      root 'pages#home'

      devise_for :users, controllers: { sessions: "users/sessions", registrations: "users/registrations", confirmations: "users/confirmations", passwords: "users/passwords" }, :skip => [:sessions]
  as :user do
    get 'sign_in' => 'users/sessions#new', :as => :new_user_session
    post 'sign_in' => 'users/sessions#create', :as => :user_session
    match 'sign_out' => 'users/sessions#destroy', :as => :destroy_user_session,
      :via => Devise.mappings[:user].sign_out_via
  end

    end

即使我有 route_path 它也会抛出错误。

尝试在范围块中编写路由。

devise_scope :user do
    # write all your routes inside this block
end

您可以在此处找到有关范围的更多信息

https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes