# Customized Route Resource Helper URLs (to not use 'id')

**URL:** <https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724>\
**Category:** Rails\
**Created:** [April 12, 2010, 7:51am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724 "2010-04-12T07:51:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sethwillits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sethwillits](https://www.ruby-forum.com/u/sethwillits)\
**Post date:** [April 12, 2010, 7:51am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724/1 "2010-04-12T07:51:07Z")

</div>

Say I have a “Member” ActiveRecord object with a typical integer id  
attribute, and a string ‘username’ attribute.

If I generate routes for members using map.resources :members, then the  
output from the edit helper is:  
edit\_member\_path(@member) =\> “members/23/edit”

My goal is that I really want:  
edit\_member\_path(@member) =\> “members/billybob/edit”

Where instead of using .id it uses .username so that the links generated  
by all of the different helper methods are prettier and memorable.

Is this possible via some kind of option? Can I simply replace these  
helper methods with new implementations? I don’t even know where these  
implementations are or what they really look like.

Thanks.

---

<div class="post-metadata">

**Author:** ![sethwillits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sethwillits](https://www.ruby-forum.com/u/sethwillits)\
**Post date:** [April 12, 2010, 9:21am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724/2 "2010-04-12T09:21:18Z")

</div>

You need to change in routes.rb file for getting name instead of id…

---

<div class="post-metadata">

**Author:** ![sethwillits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sethwillits](https://www.ruby-forum.com/u/sethwillits)\
**Post date:** [April 13, 2010, 1:25am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724/3 "2010-04-13T01:25:57Z")

</div>

Change what exactly? The resources method does not have options to  
customize the behavior of the helper methods.

---

<div class="post-metadata">

**Author:** ![sethwillits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sethwillits](https://www.ruby-forum.com/u/sethwillits)\
**Post date:** [April 13, 2010, 3:47am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724/4 "2010-04-13T03:47:13Z")

</div>

Seth,

This article may be helpful.

> **[Pain-Free Pretty URLs in Rails | Viget](https://www.viget.com/articles/pain-free-pretty-urls-in-rails/)**
>
> When working recently on a client project in a later stage of development, it became clear that the client wanted “pretty” URLs for specific models in the application. In particular, they wanted some URLs without an id, meaning the normal Rails...

Anthony C.

> **[Commonthread](https://commonthread.com)**
>
> Instantly connect and build rapport with anyone you meet, in person or online.

---

<div class="post-metadata">

**Author:** ![sethwillits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sethwillits](https://www.ruby-forum.com/u/sethwillits)\
**Post date:** [April 13, 2010, 3:59am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724/5 "2010-04-13T03:59:21Z")

</div>

Aha! That was even better than I hoped for. to\_param is exactly what I  
needed. Thanks

---

<div class="post-metadata">

**Author:** ![sethwillits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@sethwillits](https://www.ruby-forum.com/u/sethwillits)\
**Post date:** [April 13, 2010, 8:42am UTC](https://www.ruby-forum.com/t/customized-route-resource-helper-urls-to-not-use-id/186724/6 "2010-04-13T08:42:47Z")

</div>

what useful it has

2010/4/13 Seth W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
