Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails: How do you get the previous URL?

How to get the previous URL in Rails? Not the URL that you got a request from, but the one before that?

Because I'm getting an AJAX request, and I need the URL for the page they are currently on (or the URL before the AJAX).

like image 469
NullVoxPopuli Avatar asked Jan 10 '11 22:01

NullVoxPopuli


People also ask

How do I get the url in Ruby?

You can write request. url instead of request. request_uri . This combines the protocol (usually http://) with the host, and request_uri to give you the full address.

How can you create a new Rails project?

Run RubyMine and click New Project on the Welcome Screen. Name: specify a name for the project (rails-helloworld in our case). Location: specify a path to the directory in which you want to create the project. By default, RubyMine creates a directory with the same name as the project.

Is Ruby on Rails a framework?

Ruby on Rails, sometimes known as "RoR" or just "Rails," is an open source framework for Web development in Ruby, an object-oriented programming (OOP) language similar to Perl and Python.


1 Answers

Try to use HTTP_REFERER.

In Rails: request.referrer or request.headers["HTTP_REFERER"]

like image 56
gayavat Avatar answered Oct 06 '22 08:10

gayavat