Skip to content

Instantly share code, notes, and snippets.

@shirashin
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save shirashin/64bd86c4d895ecc48c95 to your computer and use it in GitHub Desktop.

Select an option

Save shirashin/64bd86c4d895ecc48c95 to your computer and use it in GitHub Desktop.
Deviseで認証失敗時にrootに遷移するようにする
# lib/custom_failure.rb[new]
class CustomFailure < Devise::FailureApp
def redirect_url
root_url # 遷移先
end
def respon
if http_auth?
http_auth
else
redirect
end
end
end
# config\application.rb[add]
config.autoload_paths += %W(#{config.root}/lib)
# config/initializers/devise.rb[add]
config.warden do |manager|
manager.failure_app = CustomFailure
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment