MyApp::Application.routes.draw do constraints DomainConstraint.new(['subdomain.domain.com', 'another.domain.com']) do resources :foo end end