Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the sign_in url for Devise

How do you change the sign in path for Devise when using a before_filter :athenticate user?

I have the following in a Posts controller.

eg:

class PostsController < ApplicationController
    before_filter :authenticate_user!

    def index
        @posts = Post.all
    end
end

At the moment it automatically goes to '/users/sign_in'

I'd like to use '/login'

like image 677
onepixelsolid Avatar asked Dec 06 '22 23:12

onepixelsolid


2 Answers

Sorted for now folks, using the devise_for method.

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

So now the sign_in path is 'accounts/login'

like image 111
onepixelsolid Avatar answered Dec 09 '22 13:12

onepixelsolid


That solution doesn't modify the resource path for sign_in.

I did however sort it out via the devise_for method. eg:

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

So now the sign_in path is 'accounts/login'

like image 25
a.wilson13 Avatar answered Dec 09 '22 13:12

a.wilson13