# Need some assistance with routing -- 'resource' using natural key

**URL:** <https://www.ruby-forum.com/t/need-some-assistance-with-routing-resource-using-natural-key/138021>\
**Category:** Rails\
**Created:** [May 19, 2008, 4:11pm UTC](https://www.ruby-forum.com/t/need-some-assistance-with-routing-resource-using-natural-key/138021 "2008-05-19T16:11:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isak\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Isak\_H](https://www.ruby-forum.com/u/Isak_H)\
**Post date:** [May 19, 2008, 4:11pm UTC](https://www.ruby-forum.com/t/need-some-assistance-with-routing-resource-using-natural-key/138021/1 "2008-05-19T16:11:53Z")

</div>

I want to create a resource, let’s say ‘cars’, which are accessed by  
license\_number rather than id.  
The column in question is guaranteed to be unique and unchanging (and  
no, it’s not actually a car table).

Best way to go about this?

Thank you,  
Isak

---

<div class="post-metadata">

**Author:** ![Isak\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@Isak\_H](https://www.ruby-forum.com/u/Isak_H)\
**Post date:** [May 19, 2008, 6:16pm UTC](https://www.ruby-forum.com/t/need-some-assistance-with-routing-resource-using-natural-key/138021/2 "2008-05-19T18:16:20Z")

</div>

class Cars \< ActiveRecord::Base  
…  
def to\_param  
return self.license\_number  
end  
…  
end
