How to convert url /contr../action/6.0 to /cont../action/6?

I am using a legacy db which has the column for the
primary key defined as a decimal number rather than
an integer, even though only integer values are stored
in in.

When rails generates a url it is of the form
/controller/action/123.0

This works, but I would prefer

/controller/action/123

What would be the best way to automatically force the
convesion to integers? I have attempted to
redefined the ‘id’ method in the model to convert
the value to an integer, but this does not work.

Thanks in advance,
donmc

On 12-Dec-05, at 11:41 AM, don mc wrote:

/controller/action/123

What would be the best way to automatically force the
convesion to integers? I have attempted to
redefined the ‘id’ method in the model to convert
the value to an integer, but this does not work.

Try accessing the value before it’s type casted. Example,

account.id_before_type_cast

/Jeff

Thanks Jeff,
Don

Jeffrey H. wrote:

On 12-Dec-05, at 11:41 AM, don mc wrote:

/controller/action/123

What would be the best way to automatically force the
convesion to integers? I have attempted to
redefined the ‘id’ method in the model to convert
the value to an integer, but this does not work.

Try accessing the value before it’s type casted. Example,

account.id_before_type_cast

/Jeff

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs