how can I get the subdomain value in rails, is there a built-in way to do this?
e.g.
test123.example.com
I want the test123 part of
In case you are working with a string, and assuming it can be a true URI, you can do this to extract the subdomain.
require 'uri' uri = URI.parse('http://test123.example.com') uri.host.split('.').first => "test123"
https://stackoverflow.com/a/13243810/3407381