# My id's are all float?

**URL:** <https://www.ruby-forum.com/t/my-ids-are-all-float/110262>\
**Category:** Rails\
**Created:** [July 24, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/my-ids-are-all-float/110262 "2007-07-24T19:21:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmorin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@dmorin](https://www.ruby-forum.com/u/dmorin)\
**Post date:** [July 24, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/my-ids-are-all-float/110262/1 "2007-07-24T19:21:03Z")

</div>

I’m using Oracle to back my Rails app, and I noticed somewhere along the  
line that if my ID is declared as NUMBER then it wants to show up as  
“123.0” whenever I ask for it (i.e. link\_to and other things). This  
didn’t seem to be a problem, so I was ignoring it.

Recently upgraded to Rails 1.2, however, and now that doesn’t route  
anymore. Is there some place where I can set this on a more  
application/global level so that I don’t have to go through every single  
rhtml page and add stuff like @plan.id.to\_i to everything?

---

<div class="post-metadata">

**Author:** ![dmorin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@dmorin](https://www.ruby-forum.com/u/dmorin)\
**Post date:** [July 26, 2007, 12:46am UTC](https://www.ruby-forum.com/t/my-ids-are-all-float/110262/2 "2007-07-26T00:46:17Z")

</div>

> I’m using Oracle to back my Rails app, and I noticed somewhere along the  
> line that if my ID is declared as NUMBER then it wants to show up as  
> “123.0” whenever I ask for it (i.e. link\_to and other things). This  
> didn’t seem to be a problem, so I was ignoring it.
> 
> Recently upgraded to Rails 1.2, however, and now that doesn’t route  
> anymore. Is there some place where I can set this on a more  
> application/global level so that I don’t have to go through every single  
> rhtml page and add stuff like @plan.id.to\_i to everything?

In your models you could add the following:

def to\_param  
id.to\_i rescue id  
end

And you could set things up so that that all your models inherit from  
this  
model or you could make this a module and include it, or just paste it  
into all of your models.

Note this will only work if you link\_to using :id =\> @plan _not_ :id =\>  
@plan.id

-philip
