Get Previous Page Url and its parametes

Learning with Earning


previous_request_url = request.headers["Referer"]

In Rails
redirect_to :back
functionality causes you to go back to the url you hit before your current url.


url = URI.parse('http://www.abc.com?page=4&node=3')
parameters = CGI.parse(url.query)
# parameters is now {"page"=>["4"], "node"=>["3"]}
page = parameters['page'].first
# page== '4'

CGI.parse

URI.parse

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s