Get Previous Page Url and its parametes



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

Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , ,
Posted in Ruby Little Codes
One comment on “Get Previous Page Url and its parametes

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

StackOverFlow
Categories
Archives
%d bloggers like this: