# Creating meaningful urls, (changing default)

**URL:** <https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265>\
**Category:** Rails\
**Created:** [July 13, 2006, 4:32pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265 "2006-07-13T16:32:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [July 13, 2006, 4:32pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/1 "2006-07-13T16:32:46Z")

</div>

Hi,

Urls in ruby are as defualt set to :controller/:action/:id

How can I change it to somthing like this  
:controller/:action/:id/#random title#

#random title# may be a variable or taken from a field in the database

thanks  
scott

---

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [July 13, 2006, 4:44pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/2 "2006-07-13T16:44:08Z")

</div>

scot wrote:

> How can I change it to somthing like this  
> :controller/:action/:id/#random title#

The default answer would be don’t. Resist the urge. Your primary keys  
aren’t combined keys, your Urls don’t need to be either.

But I know there are many reasons for wanting this. Here’s one take:

[http://blog.hasmanythrough.com/articles/2006/07/07/more-on-naming-and-the-crud](http://blog.hasmanythrough.com/articles/2006/07/07/more-on-naming-and-the-crud)

If you can live with :controller/:action/:id-#random title# instead that  
might be the easiest way to go.

I’m pretty sure there is an easy way to get exactly what you’re after  
too, but I’ll let someone who understands routes better chime in with  
the details.

Matt G.  
[http://mattgriffith.net](http://mattgriffith.net)

---

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [July 13, 2006, 4:57pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/3 "2006-07-13T16:57:35Z")

</div>

Matt G. wrote:

> scot wrote:
> 
> > How can I change it to somthing like this  
> > :controller/:action/:id/#random title#
> 
> The default answer would be don’t. Resist the urge. Your primary keys  
> aren’t combined keys, your Urls don’t need to be either.

SEO is the main reason for wanting to change the defult url layout,  
thanks for the link. Given me a couple more ideas for url layouts.

---

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [July 13, 2006, 5:00pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/4 "2006-07-13T17:00:37Z")

</div>

scot wrote:

> How can I change it to somthing like this  
> :controller/:action/:id/#random title#

[http://plasmasturm.org/log/358/](http://plasmasturm.org/log/358/)

Eric

---

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [July 14, 2006, 6:22pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/5 "2006-07-14T18:22:02Z")

</div>

scot wrote:

> nice link, exactly what I need to do, any suggestions on how to go about  
> doing this?

[http://www.notsostupid.com/blog/2006/07/07/urls-on-rails/](http://www.notsostupid.com/blog/2006/07/07/urls-on-rails/)

Eric

---

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [July 14, 2006, 3:11pm UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/6 "2006-07-14T15:11:21Z")

</div>

Eric A. wrote:

> scot wrote:
> 
> > How can I change it to somthing like this  
> > :controller/:action/:id/#random title#
> 
> [Transparent opaque changeable permanent URIs // plasmasturm.org](http://plasmasturm.org/log/358/)
> 
> Eric

nice link, exactly what I need to do, any suggestions on how to go about  
doing this?

---

<div class="post-metadata">

**Author:** ![scot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/77aa72/32.png) [@scot](https://www.ruby-forum.com/u/scot)\
**Post date:** [February 11, 2008, 10:35am UTC](https://www.ruby-forum.com/t/creating-meaningful-urls-changing-default/98265/7 "2008-02-11T10:35:40Z")

</div>

i m also looking for the same…

scot wrote:

> Hi,
> 
> Urls in ruby are as defualt set to :controller/:action/:id
> 
> How can I change it to somthing like this  
> :controller/:action/:id/#random title#
> 
> #random title# may be a variable or taken from a field in the database
> 
> thanks  
> scott
