Skip to content

Commit

Permalink
Add CHANGELOG entry and more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Aug 14, 2012
1 parent 49c503a commit fe7fb93
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
30 changes: 30 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,5 +1,35 @@
## Rails 4.0.0 (unreleased) ##

* Add Routing Concerns to declare common routes that can be reused inside
others resources and routes.

Code before:

resources :messages do
resources :comments
end

resources :posts do
resources :comments
resources :images, only: :index
end

Code after:

concern :commentable do
resources :comments
end

concern :image_attachable do
resources :images, only: :index
end

resources :messages, concerns: :commentable

resources :posts, concerns: [:commentable, :image_attachable]

*David Heinemeier Hansson + Rafael Mendonça França*

* Allow data attributes to be set as a first-level option for form_for, so you can write `form_for @record, data: { behavior: 'autosave' }` instead of `form_for @record, html: { data: { behavior: 'autosave' } }` *DHH*

* Deprecate `button_to_function` and `link_to_function` helpers.
Expand Down
8 changes: 6 additions & 2 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -1591,11 +1591,15 @@ def name_for_action(as, action) #:nodoc:
# resources :comments
# end
#
# concern :image_attachable do
# resources :images, only: :index
# end
#
# These concerns are used in Resources routing:
#
# resources :messages, concerns: :commentable
# resources :messages, concerns: [:commentable, :image_attachable]
#
# or in a given scope:
# or in a scope or namespace:
#
# namespace :posts do
# concerns :commentable
Expand Down
6 changes: 6 additions & 0 deletions guides/source/routing.textile
Expand Up @@ -281,12 +281,18 @@ Routing Concerns allows you to declare common routes that can be reused inside o
concern :commentable do
resources :comments
end

concern :image_attachable do
resources :images, only: :index
end
</ruby>

These concerns can be used in resources to avoid code duplication and share behavior across routes.

<ruby>
resources :messages, concerns: :commentable

resources :posts, concerns: [:commentable, :image_attachable]
</ruby>

Also you can use them in any place that you want inside the routes, for example in a scope or namespace call:
Expand Down

0 comments on commit fe7fb93

Please sign in to comment.