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

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

Add Comment


  • 3 Answer(s)

    Here the solution:

    Using request.original_url to get the current URL. Documented at original_url method, the code is:

    def original_url
        base_url + original_fullpath
    end
    
    Answered on December 14, 2018.
    Add Comment

    Simple Explation:

    The Ruby on Rails 3.0 method is  request.fullpath.

    Answered on December 14, 2018.
    Add Comment

    Result:

      Using url_for(:only_path => false) .

     

    Answered on December 14, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.