I am trying to get the hostname of the machine which a rails application is running on from the controller.
What would be the best way to do this taking into account it should work on both windows and linux?
All you have to do is look at the request object in your controller:
request.host_with_port
or if you don't want the port, just
request.host
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With