Question

I have different views for desktop and mobile site. If site is opened from mobile device then it will be redirected to m.domain_name

root :to => "home#index", constraints: {subdomain: 'm'||'m.staging'}
root :to => 'desktop#index'

It works fine for 'm' subdomain however it isn't working for m.staging subdomain

Was it helpful?

Solution

If you use Request based constraint, the request property should return String, not true/false. Try the same using a lambda,

root :to => "home#index",
constraints: lambda { |request| ['m','m.staging'].include?(request.subdomain) }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top