Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/murloc/action_dispatch/routing/mapper.rb
Overview
Monkey patching for adding in locale urls rubocop:disable Metrics/LineLength
Instance Method Summary collapse
Instance Method Details
#in_locales(locales, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/murloc/action_dispatch/routing/mapper.rb', line 6 def in_locales(locales, &block) scope_name = ':locale' scope_args = { locale: /#{locales.join("|")}/ } scope(scope_name, scope_args, &block) match '', to: redirect { |_, request| "#{I18n.locale}#{query_params(request)}" }, via: :all match '*path', to: redirect { |params, request| "#{I18n.locale}#{path_params(params)}#{query_params(request)}" }, constraints: { path: %r{(?!(#{I18n.available_locales.join("|")})\/).*} }, via: :all end |