From d08810e2a6ef1597bfa7a1604f9e671a6f46c4bb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 13 May 2014 14:47:04 -0700 Subject: extend with a module then use define_method no need for redefine_method --- actionpack/lib/action_dispatch/routing/mapper.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 4c20974ac7..d75ea9394c 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -578,18 +578,15 @@ module ActionDispatch _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 -- cgit v1.2.3