-
-
Save palkan/73f6e2c203c26c46574ef5832a446643 to your computer and use it in GitHub Desktop.
[Rails] Multifile routing for https://evilmartians.com/chronicles/zero-downtime-rebranding
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
# config/application.rb | |
module MyCoolApp | |
class Application < Rails::Application | |
# ... | |
# Load routes from config/routes folder | |
# NOTE: Order of route matters! It's better to not have routing conflicts, but if you have them, | |
# make sure to load routes in the correct order. | |
# In our case we must prepend all separate routes before main routes.rb | |
Dir[Rails.root.join('config/routes/**/*.rb')].each { |f| config.paths["config/routes.rb"].unshift(f) } | |
# ... | |
end | |
end |
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
# config/routes/callbacks.rb | |
MyCoolApp::Application.routes.draw do | |
# We also add subdomain constraint here | |
scope module: :callbacks, as: :callbacks, constraints: { subdomain: 'callbacks' } do | |
namespace :"third-party" do | |
resource :mail, only: [] do | |
post :notify | |
end | |
resource :web_hooks, only: [] do | |
post :verify | |
end | |
resource :payment, only: [] do | |
post :status | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment