更改Devise的sign_in url

在使用before_filter:athenticate用户时,如何更改Devise的登录路径?

我在post控制器中有以下内容。

例如:

class PostsController < ApplicationController before_filter :authenticate_user! def index @posts = Post.all end end 

目前它会自动转到’/ users / sign_in’

我想使用’/ login’

使用devise_for方法为现在的人排序。

 devise_for :users, :controllers => { :registrations => 'registrations' }, :path => 'accounts', :path_names => { :sign_in => 'login', :sign_up => 'new', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification' } 

所以现在sign_in路径是’accounts / login’

该解决方案不会修改sign_in的资源路径。

然而,我通过devise_for方法对其进行了排序。 例如:

 devise_for :users, :controllers => { :registrations => 'registrations' }, :path => 'accounts', :path_names => { :sign_in => 'login', :sign_up => 'new', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification' } 

所以现在sign_in路径是’accounts / login’

我认为你要找的信息在这里: https : //github.com/plataformatec/devise/wiki/How-To : -Change- the-default- sign_in-and-sign_out-routes

从文档中窃取:

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

在你的情况下你会使用:post而不是:user我相信。 它迟到了,我很模糊,但我认为应该这样做。