Skip to content

Instantly share code, notes, and snippets.

@joshmn joshmn/routes.rb
Created Sep 28, 2018

Embed
What would you like to do?
actual routes
class SiteConstraint
def matches?(request)
request.subdomain != 'my' && request.domain != 'localhost'
end
end
class AppConstraint
def matches?(request)
request.subdomain === 'my' || request.domain == 'localhost'
end
end
class ShortUrlConstraint
def matches?(request)
request.domain == 'tnvm.io' || request.raw_host_with_port == 'tnvm.lvh.me:3000'
end
end
Rails.application.routes.draw do
constraints ShortUrlConstraint.new do
get '*unmatched_route', to: redirect('https://my.tinyvoicemail.com/')
end
constraints SiteConstraint.new do
root :to => 'site/pages#root'
get '/developers' => 'site/pages#developers'
get '/swagger' => redirect("https://my.tinyvoicemail.com/swagger")
get '/instructions' => 'site/pages#instructions'
get '/faq' => 'site/pages#faq'
get '/terms' => 'site/pages#tos'
get '/tos' => 'site/pages#tos'
get '/privacy' => 'site/pages#privacy'
end
constraints AppConstraint.new do
resources :messages
mount API => '/'
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
root to: 'pages#root'
end
if Rails.env.production?
get '*unmatched_route', to: 'application#route_not_found', constraints: lambda { |req|
req.path.exclude? 'rails/active_storage'
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.