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?
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 => @plannot :id => @plan.id
-philip
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.