# Applying style to the URLs

**URL:** <https://www.ruby-forum.com/t/applying-style-to-the-urls/81828>\
**Category:** Rails\
**Created:** [January 15, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/applying-style-to-the-urls/81828 "2007-01-15T15:12:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [January 15, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/applying-style-to-the-urls/81828/1 "2007-01-15T15:12:20Z")

</div>

Hi you all,  
I have a link with two params:  
\<%= link\_to “John S.”, { :action =\> “filtered\_list”, :value =\> “John  
Smith”, :property=\> “primaryCharacter” }, :post =\> true %\>

The URL appears as:  
/wiki/filtered\_list?value=John+Smith&property=primaryCharacter

My question is, could I get another style in the link, such as:  
/wiki/filtered\_list/John+Smith/primaryCharacter  
(I mean, in the same way as when we use :id param)

Or even hide the params on the url? (this could be eventually done by  
using a form with hidden fields, but this is not my idea…)

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [January 15, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/applying-style-to-the-urls/81828/2 "2007-01-15T16:37:00Z")

</div>

Sure, in routes.rb…

map.connect '/wiki/filtered\_list/:value/:property, :controller =\>  
‘wiki’, :action =\> ‘filtered\_list’

You could also do something like this…

map.connect '/wiki/list/:value/:property, :controller =\>  
‘wiki’, :action =\> ‘filtered\_list’

In other words, the URL doesn’t have to match the controller or  
action names.

–  
Building an e-commerce site with Rails?  
[http://www.agilewebdevelopment.com/rails-ecommerce](http://www.agilewebdevelopment.com/rails-ecommerce)

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [January 15, 2007, 4:41pm UTC](https://www.ruby-forum.com/t/applying-style-to-the-urls/81828/3 "2007-01-15T16:41:02Z")

</div>

You should be able to do this in your routes:

map.connect ‘/wiki/filtered\_list/:value/:property’, :controller =\>  
‘wiki’, :action =\> ‘filtered\_list’

The url should then be formatted as per your question. This is just  
off the top of my head and could likely be improved on, but it should  
give the idea.

Hope that helps,

Steve

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [January 15, 2007, 4:41pm UTC](https://www.ruby-forum.com/t/applying-style-to-the-urls/81828/4 "2007-01-15T16:41:02Z")

</div>

Damaris F. wrote:

> /wiki/filtered\_list/John+Smith/primaryCharacter  
> (I mean, in the same way as when we use :id param)
> 
> Or even hide the params on the url? (this could be eventually done by  
> using a form with hidden fields, but this is not my idea…)

Damaris,  
edit routes.rb in config to cutomize how your URL’s would look, for  
example:

map.connect “wiki/:action/:value/:property”, :controller =\>  
‘your\_controller’

hope that helps,  
Bojan

–  
Bojan M.  
Informatika Mihelac, Bojan M. s.p. | [www.informatikamihelac.com](http://www.informatikamihelac.com)  
 → tools, scripts, tricks from our code lab: [http://source.mihelac.org](http://source.mihelac.org)

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [January 15, 2007, 6:57pm UTC](https://www.ruby-forum.com/t/applying-style-to-the-urls/81828/5 "2007-01-15T18:57:07Z")

</div>

Wow!

Thanks all of you! 😃
