diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-10 00:06:16 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-13 21:43:18 -0300 |
commit | 0bd7b07dff253e0fc2d01644371680bafa0df372 (patch) | |
tree | a758df96d03e3756d22b7d588d9fabf976eb31d4 /actionpack/lib/action_dispatch/routing | |
parent | 546497d027f9e4e55e99dbf7b499bb091d6b5d24 (diff) | |
download | rails-0bd7b07dff253e0fc2d01644371680bafa0df372.tar.gz rails-0bd7b07dff253e0fc2d01644371680bafa0df372.tar.bz2 rails-0bd7b07dff253e0fc2d01644371680bafa0df372.zip |
Add CHANGELOG entry and documentation for Routing Concerns
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 5ff2420921..ea5028a7c0 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1584,11 +1584,49 @@ module ActionDispatch end end + # Routing Concerns allows you to declare common routes that can be reused + # inside others resources and routes. + # + # concern :commentable do + # resources :comments + # end + # + # concern :image_attachable do + # resources :images, only: :index + # end + # + # These concerns are used in Resources routing: + # + # resources :messages, concerns: [:commentable, :image_attachable] + # + # or in a scope or namespace: + # + # namespace :posts do + # concerns :commentable + # end module Concerns + # Define a routing concern using a name. + # + # concern :commentable do + # resources :comments + # end + # + # Any routing helpers can be used inside a concern. def concern(name, &block) @concerns[name] = block end + # 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 def concerns(*names) names.flatten.each do |name| if concern = @concerns[name] |