# Page navigation with link\_to

**URL:** <https://www.ruby-forum.com/t/page-navigation-with-link-to/112051>\
**Category:** Rails\
**Created:** [August 14, 2007, 6:23pm UTC](https://www.ruby-forum.com/t/page-navigation-with-link-to/112051 "2007-08-14T18:23:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [August 14, 2007, 6:23pm UTC](https://www.ruby-forum.com/t/page-navigation-with-link-to/112051/1 "2007-08-14T18:23:07Z")

</div>

How do you accomplish page navigation with link\_to. In other words I  
want some way for \<%= link\_to … %\> to output,

Name

Is this possible?

Best,  
Sam

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [August 14, 2007, 6:38pm UTC](https://www.ruby-forum.com/t/page-navigation-with-link-to/112051/2 "2007-08-14T18:38:37Z")

</div>

You can specify an anchor in any \_to functions with :anchor. Like so:

\<%= link\_to “Name”, :controller =\> ‘controller’, :action =\>  
‘action’, ⚓ ‘PAGE\_NAV’ %\>

You may also want to set :skip\_relative\_url\_root to false if you need  
the root explicitly set.

j

On Aug 14, 9:23 am, Sam W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [August 15, 2007, 9:56pm UTC](https://www.ruby-forum.com/t/page-navigation-with-link-to/112051/3 "2007-08-15T21:56:33Z")

</div>

hi sam,  
you can do this as joshua said,  
and  
some other methods, may be like this

1. 

```
writer your on helper, some thing like this,
(you can send what ever extra options you want and handle it

```

here,)

```
    def my_link_to_function(options)
         "<a href='#{RAILS_ROOT}/#{options[:url]}'>

```

#{options[:display\_text]} "  
end  
2)  
one more options is that link\_to internally uses content\_tag so  
you can pass  
directly pass :href options to link\_to. (may be this leads to a  
kind of hard coding)

P.s: sorry, if i din’t answer to your point.

On Aug 14, 9:23 pm, Sam W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
