Is there a way to ask the Route system what controller and action
mapping will be used, given a hash containing :controller and :action?
I am trying to generalize the case where there is a button bar (e.g.
tabbed pages) having one image shown if you are presently visiting
that page, and another shown if you are not presently visiting that
page (e.g. an "active" and an "inactive" image for each
state).
The trouble I''m having is that when Routes are involved, or if there
are other parameters in the URI, then calling current_page? is not
sufficient. For example, if I have a Route that maps "" to
{:controller => "info", :action => "welcome"} then the
comparison
involving @request.request_uri used in the current_page? method will
not correctly deduce that "/" is in fact equal to {:controller =>
"info", :action => "welcome"} (see below for
UrlHelper#current_page?). Thus, current_page? returns false when it
should return true (in my case).
So the trail that I''ve taken is this: @request.path_parameters is a
hash containing the actual page that I''m visiting (after Routes are
taken in to account). This is consistent, regardless of which
routing map got me here. Now, the question is, given
some :controller and :action, how do I get a translated hash likewise
containing :controller and :action, but taking into account any
routing that may occur in between?
Thanks,
Duane Johnson
(canadaduane)
ActionView::Helpers::UrlHelper
def current_page?(options)
url_for(options) == @request.request_uri
end
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails