Skip to content
Browse files

Go back to alias_method_chain to get method inclusion in the right order

  • Loading branch information...
1 parent 3ee9ba3 commit 1342a6f381ab64c0045b2465d4dbfd1113f9ee53 @jeremy jeremy committed Jul 3, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 lib/action_dispatch/routing/concerns.rb
View
18 lib/action_dispatch/routing/concerns.rb
@@ -1,4 +1,5 @@
require 'action_dispatch'
+require 'active_support/core_ext/module/aliasing'
module ActionDispatch::Routing::Mapper::Concerns
def concern(name, &block)
@@ -20,29 +21,34 @@ def concerns(*names)
module ActionDispatch::Routing::Mapper::ResourcesWithConcerns
extend ActiveSupport::Concern
- def resource(*resources, &block)
+ included do
+ alias_method_chain :resource, :concerns
+ alias_method_chain :resources, :concerns
+ end
+
+ def resource_with_concerns(*resources, &block)
if (options_with_concerns = resources.last).is_a?(Hash)
named_concerns = options_with_concerns.delete(:concerns)
- super(*resources) do
+ resource_without_concerns(*resources) do
concerns(named_concerns)
block.call if block_given?
end
else
- super(*resources, &block)
+ resource_without_concerns(*resources, &block)
end
end
- def resources(*resources, &block)
+ def resources_with_concerns(*resources, &block)
if (options_with_concerns = resources.last).is_a?(Hash)
named_concerns = options_with_concerns.delete(:concerns)
- super(*resources) do
+ resources_without_concerns(*resources) do
concerns(named_concerns)
block.call if block_given?
end
else
- super(*resources, &block)
+ resources_without_concerns(*resources, &block)
end
end
end

0 comments on commit 1342a6f

Please sign in to comment.
Something went wrong with that request. Please try again.