Change sign_in pointer for Devise

How do you change the input path for Devise when using the before_filter: user authentication option?

I have the following in the message controller.

eg:

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

Currently, it automatically goes to '/ users / sign_in'

I would like to use '/ login'

+4
source share
3 answers

People are currently sorted 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"

+10
source

This solution does not change the resource path for sign_in.

I still parsed it using 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"

+2
source

I think the information you are looking for is here: https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes

Stolen from documents:

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

In your case, you will use: post instead of: the user I believe. Its late, and I'm unclear, but I think that should do it.

+1
source

Source: https://habr.com/ru/post/1337094/


All Articles