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

后端 未结 30 2487
佛祖请我去吃肉
佛祖请我去吃肉 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:11

    None of the suggestions here in the thread helped me sadly, except the one where someone said he used the debugger to find what he looked for.

    I've created some custom error pages instead of the standard 404 and 500, but request.url ended in /404 instead of the expected /non-existing-mumbo-jumbo.

    What I needed to use was

    request.original_url
    

提交回复
热议问题