Repository navigation
How To: Redirect with locale after authentication failure
LucasAU edited this page Feb 18, 2015
·
5 revisions
Set your locale and make your default_url_options a class method in your ApplicationController
def set_locale I18n.locale = params[:locale] end def self.default_url_options(options={}) options.merge({ :locale => I18n.locale }) end
Note: this differs from the Rails Internationalization (I18n) API Guide, but is required by the implementation of the Devise FailureApp (it calls ApplicationController.default_url_options(*args) in its default_url_options method).
Without this change, and if your routes are setup to require a locale, you will see errors like this on authentication failure:
ActionController::UrlGenerationError (No route matches {:action=>"new", :controller=>"devise/sessions"} missing required keys: [:locale])