def current_url
#       request.env['PATH_INFO'] # old behaviour
      if request.respond_to? :url # for rack >= 2.0.0
        request.url
      elsif request.respond_to? :original_url # for rails >= 4.0.0
        request.original_url
      else
        request.env['REQUEST_URI']
      end
    end
def current_url
#       request.env['PATH_INFO'] # old behaviour
      if request.respond_to? :url # for rack >= 2.0.0
        request.url
      elsif request.respond_to? :original_url # for rails >= 4.0.0
        request.original_url
      else
        request.env['REQUEST_URI']
      end
    end
Return the complete URL of the current request.
 Note that this path does include ALL query parameters and the host name,
 thus allowing you to navigate back and forth between different hosts. If you
 want the pre-0.1.0 behaviour back, just overwrite this method
 in your controller so it returns "request.env['PATH_INFO']".
 Example:

  <%= link_to my_messages_path referrer_param => current_path %>