Method: ActionDispatch::Routing::Mapper::Concerns#concerns

Defined in:
actionpack/lib/action_dispatch/routing/mapper.rb

#concerns(*args) ⇒ Object

Use the named concerns

resources :posts do
  concerns :commentable
end

Concerns also work in any routes helper that you want to use:

namespace :posts do
  concerns :commentable
end


2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 2161

def concerns(*args)
  options = args.extract_options!
  args.flatten.each do |name|
    if concern = @concerns[name]
      concern.call(self, options)
    else
      raise ArgumentError, "No concern named #{name} was found!"
    end
  end
end