# Link\_to flexibility

**URL:** <https://www.ruby-forum.com/t/link-to-flexibility/113753>\
**Category:** Rails\
**Created:** [September 4, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/link-to-flexibility/113753 "2007-09-04T18:15:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snaggy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@snaggy](https://www.ruby-forum.com/u/snaggy)\
**Post date:** [September 4, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/link-to-flexibility/113753/1 "2007-09-04T18:15:28Z")

</div>

My website, user side, is just one controller/action

I reroute this:  
[http://www.mywebsite.com/:menu/:submenu](http://www.mywebsite.com/:menu/:submenu)

to this:  
[http://www.mywebsite.com/MyController/Index/:menu/:submenu](http://www.mywebsite.com/MyController/Index/:menu/:submenu)

so that the visitors have a nice web url like this:

[www.mywebsite.com/about\_us/my\_story](http://www.mywebsite.com/about_us/my_story)

all menu and submenu is dynamically generate from a database, the  
whole website is actually contained in the database…

> the problem is that I don’t know how to use the link\_to helper in this situation

\<%= link\_to menu.name, {:controller =\> ‘mycontroller’, :action =\>  
‘index’, :menu =\> menu.name} %\>

results in:

[http://www.mywebsite.com/myController?menu=about\_us\_us](http://www.mywebsite.com/myController?menu=about_us_us)

which works but sucks

> I could do this, but I have to create a @site variable and set it everytime

\<%= menu.name %\>

How would you solve the problem? Any idea, suggestion…  
bye  
Thanks

---

<div class="post-metadata">

**Author:** ![snaggy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cdc98d/32.png) [@snaggy](https://www.ruby-forum.com/u/snaggy)\
**Post date:** [September 5, 2007, 5:10am UTC](https://www.ruby-forum.com/t/link-to-flexibility/113753/2 "2007-09-05T05:10:13Z")

</div>

[\<%=  
menu.name %\>](http://www.mywebsite.com/myController?menu=about_us_us)
