[Rails] Can rails make use of accesskeys?
Jarkko Laine
jarkko at jlaine.net
Sun Jan 1 19:44:12 GMT 2006
On 1.1.2006, at 20.25, Morten Liebach wrote:
> I'm using Darwinports and gem installed RoR and I've been having some
> trouble with extra HTML attributes too, and I found out the {}'s are
> significant:
>
> <%= link_to "Goodbye!", {:action => "goodbye"}, :accesskey => "g",
> :title => "Bye bye!" %>
>
> Works. Whereas this:
>
> <%= link_to "Goodbye!", :action => "goodbye", :accesskey => "g",
> :title => "Bye bye!" %>
>
> Doesn't work, instead it generates a link pointing to
> "/say/goodbye?accesskey=f&title=Bye+bye%21".
>
> It's probably obvious why, and I think I know the reason. I expect to
> be sure sometime later in Agile Web Dev w. RoR, I'm just too much of a
> newbie to take my chances explaining it yet in public. :-)
link_to(name, options = {}, html_options = nil,
*parameters_for_method_reference)
The reason is that if you omit the curly braces, all of the hash
values are considered to be part of the first hash parameter of
link_to, "options". However, accesskey and title belong to the
"html_options" parameter, so you need to separate the two hashes with
curlies. Using the braces around both hashes makes it also easier to
read the code later on.
//jarkko
--
Jarkko Laine
http://jlaine.net
http://odesign.fi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2363 bytes
Desc: not available
Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060101/52763935/smime-0001.bin
More information about the Rails
mailing list