![](https://jsgrip.com/wp-content/uploads/2021/12/carbon-1-1024x705.png)
- One of the fundamental principles Rails developers follow is Donโt Repeat Yourself (DRY).๐
- We can use concerns, to avoid repeating the same routes defined.
- To eliminate code duplication rails introduced the routing method :concern.
concern :commentable do
resources :comments
end
concern :imageable do
resources :images
end
resources :users, concerns: :imageable
resources :posts, concerns: %i[commentable imageable]
The :concerns option can accept one or more routing concerns.