Permalink
Browse files

extend with a module then use define_method

no need for redefine_method
  • Loading branch information...
1 parent 6457ed4 commit d08810e2a6ef1597bfa7a1604f9e671a6f46c4bb @tenderlove tenderlove committed May 13, 2014
Showing with 4 additions and 7 deletions.
  1. +4 −7 actionpack/lib/action_dispatch/routing/mapper.rb
View
11 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -578,18 +578,15 @@ def define_generate_prefix(app, name)
_route = @set.named_routes.routes[name.to_sym]
_routes = @set
app.routes.define_mounted_helper(name)
- app.routes.singleton_class.class_eval do
- redefine_method :mounted? do
- true
- end
-
- redefine_method :_generate_prefix do |options|
+ app.routes.extend Module.new {
+ def mounted?; true; end
+ define_method :_generate_prefix do |options|
prefix_options = options.slice(*_route.segment_keys)
# we must actually delete prefix segment keys to avoid passing them to next url_for
_route.segment_keys.each { |k| options.delete(k) }
_routes.url_helpers.send("#{name}_path", prefix_options)
end
- end
+ }
end
end

0 comments on commit d08810e

Please sign in to comment.