Get hostname from Rails controller

前端 未结 4 513
一整个雨季
一整个雨季 2021-01-01 08:23

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

4条回答
  •  情深已故
    2021-01-01 09:07

    If you need the full domain path from protocol to port, try:

    full_domain_path = request.env['rack.url_scheme'] + '://' + request.host_with_port
    

提交回复
热议问题