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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s always:
I’ve got no Windows box handy with which to test this, but the docs make no mention of it being *nix specific.
Note: The require statement is not necessary for Rails 4, and probably other Rails versions as well. It is required if you are doing plain Ruby without Rails.