Getting the current URL is pretty easy, simply choose one of the following methods listed below.

Rails 3.x and up:

#{request.protocol}#{request.host_with_port}#{request.fullpath}
Rails 3.2 and up:

request.original_url