Sha256: 5651eafc2d4ae3aa3744e6b71069667a287d80d7b556386f8a36b8e40424729f

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

module TranslatableRoutes
  module ActionDispatch
    module NamedRouteCollection
      extend ActiveSupport::Concern
      
      def define_i18n_route_helper(name)
        ['url', 'path'].each do |kind|
          helper = :"#{name}_#{kind}"
          @module.remove_possible_method helper
          @module.module_eval do 
            define_method helper do |*args|
              options = args.extract_options!
              if Rails.application.config.translatable_routes.selection == :subdomain
                suffix = (options[:subdomain] ? options[:subdomain] : request.subdomain)
              else
                suffix = (options[:locale] ? options[:locale] : I18n.locale).to_s.gsub('-', '_').downcase
              end
              send ("#{name}_" + suffix.to_s + "_#{kind}"), *(args << options)
            end
          end
          helpers << helper
        end
      end
 
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translatable_routes-1.2.0 lib/translatable_routes/action_dispatch/named_route_collection.rb