Module: Umlaut::ControllerBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- ControllerLogic, ErrorHandling, UmlautConfigurable
- Included in:
- UmlautController
- Defined in:
- app/controllers/umlaut/controller_behavior.rb
Overview
All behavior from UmlautController is extracted into this module, so that we can generate a local UmlautController that includes this module, and local app can configure or over-ride default behavior.
This is really only intended to be included’d by UmlautController; other controllers may sub-class UmlautController
Instance Method Summary collapse
-
#default_url_options(*arguments) ⇒ Object
Rails over-ride to ensure locale is always included in generated URLs.
-
#set_locale ⇒ Object
Set the current locale based on request param umlaut.locale Local app can override this in UmlautController if you’d like to base locale on HTTP headers or IP address or other things.
Methods included from UmlautConfigurable
Instance Method Details
#default_url_options(*arguments) ⇒ Object
Rails over-ride to ensure locale is always included in generated URLs. We choose to explicitly include locale’s only for non-default locale. Local app may override this in UmlautController to make other choices.
36 37 38 39 40 41 42 43 |
# File 'app/controllers/umlaut/controller_behavior.rb', line 36 def (*arguments) if I18n.locale == I18n.default_locale # Don't add in param for default locale super else super.merge({ 'umlaut.locale'.to_sym => I18n.locale }) end end |
#set_locale ⇒ Object
Set the current locale based on request param umlaut.locale Local app can override this in UmlautController if you’d like to base locale on HTTP headers or IP address or other things.
27 28 29 |
# File 'app/controllers/umlaut/controller_behavior.rb', line 27 def set_locale I18n.locale = params['umlaut.locale'.to_sym] || I18n.default_locale end |