Skip to content

Instantly share code, notes, and snippets.

@mitio
Created July 26, 2012 08:10
Show Gist options
  • Save mitio/3180907 to your computer and use it in GitHub Desktop.
Save mitio/3180907 to your computer and use it in GitHub Desktop.
Rails Routes Constraints By Subdomain
constraints(lambda { |req| req.host.to_s =~ /\Aadmin./ }) do
namespace :admin, :path => '/' do
root :to => 'dashboards#show' # => that's Admin::DashboardsController#show in app/controllers/admin/dashboards_controller.rb
resources :users # => Admin::UsersController in app/controllers/admin/users_controller.rb
resources :posts # => Admin::PostsController in app/controllers/admin/posts_controller.rb
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment