Reputation: 150996
In Rails (version 3), request.url
can show
http://www.foo.com/products/123
but what about just to get
http://www.foo.com
or
http://www.foo.com/
? There are 2 apparent ways, one is using regular expression, which is not very clean, and the other is
"#{request.scheme}://#{request.host}"
and it is kind of ugly either. Is there a cleaner to do it?
Upvotes: 1
Views: 506
Reputation: 14716
This will get you what request.url
gets you, but without the path:
request.protocol + request.host_with_port
Upvotes: 3
Reputation: 1509
Should be stored in the request object. request.domain should get the info you need but use this command to retrieve all the information from the object and have a look at what is stored there
raise request.inspect
more info can be found at
http://rails.nuvvo.com/lesson/6377-action-controller-the-request-and-response-objects
Upvotes: 0