Sha256: e9a028db567d9e3ada679d9749ae1057f5d858bf3e877c8148b236d61f24958c

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 Bytes

Contents

module TranslatableRoutes
  module ActionDispatch
    module NamedRouteCollection
      extend ActiveSupport::Concern
 
      def define_i18n_url_helper(name)
        %w(path url).each do |type|
          helper = :"#{name}_#{type}"
          @module.remove_possible_method helper
          @module.module_eval do
            define_method helper do |*args|
              options = args.extract_options!
              suffix = (options[:locale] || I18n.locale).to_s.gsub('-', '_').downcase
              send "#{name}_#{suffix}_#{type}", *(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.3.3 lib/translatable_routes/action_dispatch/named_route_collection.rb