如何使用new_user_session路由从devise作为根路径?

时间:2014-10-27 12:03:22

标签: ruby-on-rails ruby devise

问题 - 我不知道如何将设计中的new_user_session路由设置为Rails app中的根路径。

Rails.application.routes.draw do
  devise_for :users
resources :dashboard
root to: "home#index"

2 个答案:

答案 0 :(得分:1)

将此行放在routes.rb

devise_scope :user do
 root :to => 'devise/sessions#new'
end

您需要设置默认会话路由。

答案 1 :(得分:0)

替换为。

devise_for :users, :controllers => {:registrations => "registrations", :sessions => "sessions"}
  devise_for :users do
    get '/users/sign_in', :to => 'devise/sessions#new', :as => :new_user_session
    get '/users/sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session
  end

和root to

devise_scope :user do
  get "/" => "sessions#new"
end