ruby on rails - Devise redirect after login fail -


all questions i've found related successful login helper after_sign_in_path_for(resource)

i have login form in index of site, , when login fails redirects "users/sign_in"

but how can redirect "site#index" when login fails?

  1. create custom_failure.rb in lib directory, with:

    class customfailure < devise::failureapp   def redirect_url     your_path   end    def respond     if http_auth?       http_auth     else       redirect     end   end end 
  2. in devise initializer, include:

      config.warden |manager|     manager.failure_app = customfailure   end 
  3. make sure rails loadin lib files, in application.rb :

    config.autoload_paths += %w(#{config.root}/lib) 

don't forget restart server.

i don't think there's easier way this. luck.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -