I am trying to set up subdomains in Rails 3 for Ryan Bates screencast on subdomains . However, this does not work for me. I have the following setup:
constraints(Subdomain) do
get 'devices' => 'devices#all'
end
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain == "admin"
end
end
Downloading the url admin.localhost:3000/devicesshould redirect me to devices#all, however I get a routing error. Routing Error No route matches [GET] "/devices"Clearly my routing is not working.
I am setting up a debugging session prywhere the comment is above and it hits, so my restriction works, but I get the following output:
[1] pry(Subdomain)> request.subdomain
=> ""
[2] pry(Subdomain)> request.subdomains
=> []
[3] pry(Subdomain)> request.host
=> "admin.localhost"
Thus, the rails do not collect the administrative part of the URL and do not put it in the subdomain variable. Although I could just simply use the host value to filter admin routes, I would like to keep it clean and correct.
?
jdoe coreyward . , , , pow xip.io . , http://admin.app_name.192.168.1.68.xip.io/devices tld > 1. , , xip admin.app_name.192.168.1.68, .