If you are using versions on your Rails API application
We often repeat the same routes.
In honor DRY we use concerns!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
concern :api_base do | |
resources :posts do | |
resources :comments | |
end | |
end | |
namespace :v1 do | |
concerns :api_base | |
end | |
namespace :v2 do | |
concerns :api_base | |
end | |
end |
rubytapas.com
Comments
Post a Comment