How do I get the current absolute URL in Ruby on Rails?

后端 未结 30 2692
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 13:47

How can I get the current absolute URL in my Ruby on Rails view?

The request.request_uri only returns the relative URL

30条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 14:23

    For Ruby on Rails 3:

    request.url
    request.host_with_port
    

    I fired up a debugger session and queried the request object:

    request.public_methods
    

提交回复
热议问题