Forum: Ruby on Rails Link_to with anchor?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ecf21acef6f0e0d734051c7392207d2f?d=identicon&s=25 Nauhaie None (nauhaie)
on 2006-09-15 15:14
Hi!

Very silly question, but how do you use link_to with an anchor, for
example:

www.website.com/articles/123#comments ?

Just can't figure out!

Thank you!
D68c82f7c95fbfb6d50d62cbfa0d8409?d=identicon&s=25 Curtis Summers (curtissummers)
on 2006-09-15 15:48
Nauhaie None wrote:
> Hi!
>
> Very silly question, but how do you use link_to with an anchor

link_to 'mylink', {:controller => â??postsâ??,
                   :action => â??showâ??,
                   :id => 10,
                   :anchor => â??commentsâ??}


From the url_for documentation:
:anchor â?? specifies the anchor name to be appended to the path. For
example, url_for :controller => â??postsâ??, :action => â??showâ??, :id => 10,
:anchor => â??commentsâ?? will produce "/posts/show/10#comments".
Ecf21acef6f0e0d734051c7392207d2f?d=identicon&s=25 Nauhaie None (nauhaie)
on 2006-09-15 15:50
Nice! Thanks a lot!
This topic is locked and can not be replied to.