alexmle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-06 01:22 UTC
Routes: query parameter keys and significant keys in routes
I''m currently facing a problem where I''d like to take parameter which is encoded into the path portion of the URL via routes on one page, and add it as a query parameter for a link to a subsequent page (linked on the current page). I would like the query parameter to be keyed by the same key that is used on the current page in the route. Here is the example: map.connect ''/:search_term/:foo/:bar'', ........ map.connect ''/:foo/:bar/:baz'', ......... I am currently on page a (the first route), and have a link to page b(second route). In the link_to method, I pass the key/value pair {:search_term => ''foo''}, but it does not appear as a query parameter on this generated link. The code in ActionController::Routing that removes this is: def extra_keys(hash, recall={}) (hash || {}).keys.map { |k| k.to_sym } - (recall || {}).keys - significant_keys end Hash is the newparameter options, and recall is the hash of current parameters. Why would you subtract recall from hash when figuring out which keys are going to be appended as query parameter keys? Best, Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---