我正在运行Rails 3.2.12和Devise 3.1,我在routes.rb中运行了这个:
devise_for :users do
get '/login' => 'devise/sessions#new', as: :login
get '/logout' => 'devise/sessions#destroy', as: :logout
end
然而,当我点击
127.0.0.1:3000/login
我得到了
No route matches [GET] "/login"
什么有效
127.0.0.1:3000/users/login
还有什么我必须这样做,以便我可以跳过输入/ users / part?
谢谢!
答案 0 :(得分:1)
devise_for :users, :path => '', :path_names => { :sign_in => 'login'}
关于在this StackOverflow post上自定义设计路径的详细信息:)
以下是一些适用于我们的实时应用的实时代码:
#User Management (Devise)
devise_for :users, :path => '', :controllers => {:sessions => 'sessions', :registrations => 'registrations'}, :path_names => { :sign_in => 'login', :password => 'forgot', :confirmation => 'confirm', :unlock => 'unblock', :registration => 'register', :sign_up => 'new', :sign_out => 'logout'}
as :user do
get 'register', :to => 'devise/registrations#new'
delete 'logout', :to => 'sessions#destroy'
end
答案 1 :(得分:0)
devise_scope :user do
get "/login" => "devise/sessions#new"
end
有关详细信息,请参阅this