rubycoloredglasses


I'm Jason, a web applications developer in the Denver, Colorado area.


Obtaining Request Domain Name for Ruby on Rails

I’m using Rails 2.3.8. To obtain the domain name for the website being requested (i.e. mysite.com, mysite.net), just reference ‘request.host’.

ruby@host = request.host

You can only reference request.host in the views, or the controller.

comments powered by Disqus