Well, it is documented, so...
But there is an actual reason. I was designing a helper that creates
links and wanted the following interface:
link_helper(optional_link_text, url, optional_html_options)
I will explain why I need the optional text in the end of the message
(you can just trust I am not that lame or read the more detailed
explanation below). I also don't want to change the order of the
parameters not to confuse everyone that is already used to the link_to
helper interface.
The problem is if I accept url to be a string (that *_url will
generate), I will have a big problem trying to differentiate the
parameters for the following hypothetical calls:
link_helper(named_route_url, {:title=>'link!!'})
link_helper("My link optional text", {:controller=>'foo'})
See, the types are the same, so I would have to investigate the hash
content to see if it is a url_options hash or a html_options hash. The
code to only parse the parameters gets 10 times bigger than the actual
helper (this is the price you pay for dynamic typing and no function
overloading)... Too much for a simple helper.
So, I just took an easier path and decided to force url to be an
url_options hash, so the parameters get really easy to parse. Using
'hash_for_*_url' instead of '*_url' seemed like a small price to pay
(if it worked).
link_helper(optional_string, url_hash_options,
optional_html_options)
I am sure there must be other use cases for the hash_for_*_url. If the
Rails Core team felt otherwise it shouldn't be exposed.
****** More details
I actually created a menu/tab generator helper. In it, every link must
have a unique identifier (actually a symbol), so it can be set as
selected (and the corresponding tab maybe be highlighted using CSS)
somewhere else in the view or controller. To reduce verbosity, if the
link text is not provided, the identifier is 'titleized' and used
instead. Some code excerpt:
<% tabs_for :menu_name do |tab| %>
<%= tab.home :controller =>'/user', :action => 'index' %>
<%= tab.profile "My profile",
hash_for_user_profile_path(current_user) %>
<%= tab.contacts hash_for_contacts_path %>
<%= tab.jobs hash_for_jobs_path, {:title=>'Just showing off'} %>
<% end %>
Cheers,
Bernardo