Forum: Ruby on Rails link_to and fragment identifiers

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.
C73cb1e21e99175a86470ad906440501?d=identicon&s=25 John Kopanas (Guest)
on 2006-05-27 01:53
(Received via mailing list)
Fragment identifiers, it took me 30 minutes just to figure out what
they are called.

I would like to be able to create url that looks like this:
post/view/id#comments

How do I do that with a link_to function?

link_to "Comments", :controller => "post", :action => "view", :id =>
post.id ???

Thanks guys! :-)

John Kopanas
http://www.kopanas.com


============================================================
http://www.soen.info - Index of online software engineering knowledge
http://www.cusec.net - Canadian University Software Engineering
Conference
http://www.soenlive.com - Presentations from CUSEC
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-05-27 03:39
(Received via mailing list)
On Friday, May 26, 2006, at 7:50 PM, John Kopanas wrote:
>
>
>
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails

link_to "Comments", :controller => "post", :action => "view", :id =>
post.id, :anchor=>'comments'

_Kevin
9ab183bb240ffd3a3966d5a615b4bdeb?d=identicon&s=25 Philip Ross (Guest)
on 2006-05-27 18:41
(Received via mailing list)
John Kopanas wrote:
> Fragment identifiers, it took me 30 minutes just to figure out what they
> are called.
>
> I would like to be able to create url that looks like this:
> post/view/id#comments
>
> How do I do that with a link_to function?
>
> link_to "Comments", :controller => "post", :action => "view", :id =>
> post.id ???

Use :anchor, e.g.

link_to "Comments",
   :controller => "post",
   :action => "view",
   :id => post.id,
   :anchor => "comments"

--
Philip Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
This topic is locked and can not be replied to.