Type:
Module

Routing Concerns allow you to declare common routes that can be reused inside others resources and routes.

1
2
3
4
5
6
7
concern :commentable do
  resources :comments
end
 
concern :image_attachable do
  resources :images, only: :index
end

These concerns are used in Resources routing:

1
resources :messages, concerns: [:commentable, :image_attachable]

or in a scope or namespace:

1
2
3
namespace :posts do
  concerns :commentable
end
concern
  • References/Ruby on Rails/Rails/Classes/ActionDispatch/ActionDispatch::ROUTING/ActionDispatch::Routing::Mapper/ActionDispatch::Routing::Mapper::Concerns

concern(name, callable = nil, &block) Instance Public methods Define a routing

2025-01-10 15:47:30
concerns
  • References/Ruby on Rails/Rails/Classes/ActionDispatch/ActionDispatch::ROUTING/ActionDispatch::Routing::Mapper/ActionDispatch::Routing::Mapper::Concerns

concerns(*args) Instance Public methods Use the named concerns

2025-01-10 15:47:30