Module: I18nRouting::RackMountRoute
- Defined in:
- lib/i18n_routing_rails3.rb
Overview
Rack::Mount::Route module Exists in order to use apropriate localized route when using url_for
Class Method Summary collapse
-
.included(mod) ⇒ Object
Alias methods in order to handle i18n routes.
Instance Method Summary collapse
-
#generate_with_i18n_routing(method, params = {}, recall = {}, options = {}) ⇒ Object
Called for dynamic route generation If a @locale is present and if this locale is not the current one => return nil and refuse to generate the route.
-
#initialize_with_i18n_routing(app, conditions, defaults, name) ⇒ Object
During route initialization, if a condition i18n_locale is present Delete it, and store it in @locale.
Class Method Details
.included(mod) ⇒ Object
Alias methods in order to handle i18n routes
369 370 371 372 |
# File 'lib/i18n_routing_rails3.rb', line 369 def self.included(mod) mod.send :alias_method_chain, :generate, :i18n_routing mod.send :alias_method_chain, :initialize, :i18n_routing end |
Instance Method Details
#generate_with_i18n_routing(method, params = {}, recall = {}, options = {}) ⇒ Object
Called for dynamic route generation If a @locale is present and if this locale is not the current one
=> return nil and refuse to generate the route
384 385 386 387 |
# File 'lib/i18n_routing_rails3.rb', line 384 def generate_with_i18n_routing(method, params = {}, recall = {}, = {}) return nil if @locale and @locale != I18n.locale.to_sym generate_without_i18n_routing(method, params, recall, ) end |
#initialize_with_i18n_routing(app, conditions, defaults, name) ⇒ Object
During route initialization, if a condition i18n_locale is present Delete it, and store it in @locale
376 377 378 379 |
# File 'lib/i18n_routing_rails3.rb', line 376 def initialize_with_i18n_routing(app, conditions, defaults, name) @locale = conditions[:i18n_locale] ? conditions.delete(:i18n_locale).source.to_sym : nil initialize_without_i18n_routing(app, conditions, defaults, name) end |