# Link\_to and fragment identifiers

**URL:** <https://www.ruby-forum.com/t/link-to-and-fragment-identifiers/61777>\
**Category:** Rails\
**Created:** [May 27, 2006, 1:53am UTC](https://www.ruby-forum.com/t/link-to-and-fragment-identifiers/61777 "2006-05-27T01:53:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [May 27, 2006, 1:53am UTC](https://www.ruby-forum.com/t/link-to-and-fragment-identifiers/61777/1 "2006-05-27T01:53:02Z")

</div>

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.kopanas.com)

============================================================  
[http://www.soen.info](http://www.soen.info) - Index of online software engineering knowledge  
[http://www.cusec.net](http://www.cusec.net) - Canadian University Software Engineering  
Conference  
[http://www.soenlive.com](http://www.soenlive.com) - Presentations from CUSEC

---

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [May 27, 2006, 3:39am UTC](https://www.ruby-forum.com/t/link-to-and-fragment-identifiers/61777/2 "2006-05-27T03:39:59Z")

</div>

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](http://lists.rubyonrails.org/mailman/listinfo/rails)

link\_to “Comments”, :controller =\> “post”, :action =\> “view”, :id =\>  
post.id, :anchor=\>‘comments’

\_Kevin

---

<div class="post-metadata">

**Author:** ![johnk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@johnk](https://www.ruby-forum.com/u/johnk)\
**Post date:** [May 27, 2006, 6:41pm UTC](https://www.ruby-forum.com/t/link-to-and-fragment-identifiers/61777/3 "2006-05-27T18:41:22Z")

</div>

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/](http://tzinfo.rubyforge.org/) – DST-aware timezone library for Ruby
