Forum: Ruby on Rails how to handle '<a name= ' links?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Patrick A. (Guest)
on 2007-02-03 20:50
(Received via mailing list)
hey all
i have a <a name="item">item</a> and im trying to do a link that way:

    link_to 'item',:action=>'show',:id=>@item+'#item'

but i get %23item instead of the #item.

any idea whats wrong?

thanx in advance

Bill W. (Guest)
on 2007-02-03 21:13
(Received via mailing list)
Hi Patrick,

Patrick A. wrote:
>    link_to 'item',:action=>'show',:id=>@item+'#item'
> but i get %23item instead of the #item

Coupla thoughts...

1) Rails may need you to use braces to parse that correctly.
e.g., link_to 'item', {:action=>'show',:id=>@item+'#item'}

2) Rails may have trouble with '#' as part of a symbol.

What's the full string you're getting back in params[:id] ?  That might
some light.

Bill W. (Guest)
on 2007-02-03 21:17
(Received via mailing list)
One more clue...

The ascii hex value for '#' is 23
Patrick A. (Guest)
on 2007-02-03 22:27
(Received via mailing list)
thanx, i found it. anchor=> does the job :)
This topic is locked and can not be replied to.