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.
John K. (Guest)
on 2006-05-27 03: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 K.
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
Kevin O. (Guest)
on 2006-05-27 05:39
(Received via mailing list)
On Friday, May 26, 2006, at 7:50 PM, John K. wrote:
>
>
>
>_______________________________________________
>Rails mailing list
>removed_email_address@domain.invalid
>http://lists.rubyonrails.org/mailman/listinfo/rails

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

_Kevin
Philip R. (Guest)
on 2006-05-27 20:41
(Received via mailing list)
John K. 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 R.
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
This topic is locked and can not be replied to.