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
352 353 354 355 |
# File 'lib/i18n_routing_rails3.rb', line 352 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
367 368 369 370 |
# File 'lib/i18n_routing_rails3.rb', line 367 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
359 360 361 362 |
# File 'lib/i18n_routing_rails3.rb', line 359 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 |