How do I get the host and port in a Rails application

前端 未结 6 1754

In a Rails Model, I want to be able to find out the host and port. For example, if I am in a test environment it would return http://localhost:3000/ and if I

6条回答
  •  暖寄归人
    2020-12-17 09:02

    you can get full uri (http://localhost:3000/ or http://my.application.com/ etc) with request_uri

    http://apidock.com/rails/ActionController/AbstractRequest/request_uri

提交回复
热议问题