Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb
index ff44849..f3a4f09 100644
--- a/actionpack/lib/action_controller/routing/route_set.rb
+++ b/actionpack/lib/action_controller/routing/route_set.rb
@@ -170,18 +170,24 @@ module ActionController
def #{selector}(*args)
#{generate_optimisation_block(route, kind)}
+ locale = #{route.segment_keys.include?(:locale) ? '{ :locale => I18n.locale || I18n.default_locale }' : '{}'}
+
opts = if args.empty? || Hash === args.first
args.first || {}
else
options = args.extract_options!
- args = args.zip(#{route.segment_keys.inspect}).inject({}) do |h, (v, k)|
+
+ segments = #{route.segment_keys.inspect}
+ #{'segments.delete(:locale) if segments.size > args.size' if route.segment_keys.include?(:locale)}
+
+ args = args.zip(segments).inject({}) do |h, (v, k)|
h[k] = v
h
end
options.merge(args)
end
- url_for(#{hash_access_method}(opts))
+ url_for(#{hash_access_method}(locale.merge(opts)))
end
protected :#{selector}
end_eval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.