instance method
current_page?
Ruby on Rails 2.2.3
Since v2.2.3Signature
current_page?(options)
True if the current request URI was generated by the given options.
Examples
Let’s say we’re in the /shop/checkout?order=desc action.
current_page?(:action => 'process') # => false current_page?(:controller => 'shop', :action => 'checkout') # => true current_page?(:controller => 'shop', :action => 'checkout', :order => 'asc) # => false current_page?(:action => 'checkout') # => true current_page?(:controller => 'library', :action => 'checkout') # => false
Parameters
-
optionsreq
Source
# File actionpack/lib/action_view/helpers/url_helper.rb, line 518
def current_page?(options)
url_string = CGI.escapeHTML(url_for(options))
request = @controller.request
# We ignore any extra parameters in the request_uri if the
# submitted url doesn't have any either. This lets the function
# work with things like ?order=asc
if url_string.index("?")
request_uri = request.request_uri
else
request_uri = request.request_uri.split('?').first
end
if url_string =~ /^\w+:\/\//
url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
else
url_string == request_uri
end
end
Defined in actionpack/lib/action_view/helpers/url_helper.rb line 518
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::UrlHelper