Ruby on Rails Devise, how to change the signal path when authentication fails?

I recently injected Devise into my new application with Omniauth, however I'm not sure how to change the default signin path in Devise so that when called:

user_authenticated!

It is redirected to the authentication controller page.
Any ideas how to do this?

EDIT: better explain my problem →

What I want - this is when a user tries to access a page that requires logon, and then sent to users / sign _in using user_authenticated before filter parameter, but I want them to be redirected to /authafter user_authenticated!not users / sign_in.

+5
source share
2 answers

In your controller:

before_filter do
  authenticate_user! rescue redirect_to auth_url
end
+2
source

I don’t think I really understood your problem, but for redirecting to a specific page it should be an implementation

class ApplicationController < ActionController::Base
  private

  def after_sign_in_path_for(resource_or_scope)
    root_path
  end
end

if you want to have a different url for the sign_in process on your routes. rb

  devise_scope :user do
    get "sign_in", :to => "devise/sessions#new"
  end

and all you need at https://github.com/plataformatec/devise/wiki

hope this is helpful

+1
source