AR converts params to integer

Hello.

It seems like AR is auto-converting the string from form into an
integer (for an attribute of an integer column). However, for custom
validation I don't want it to do this - I want to have access to the
actual string.

I create the model like this:

@model = Model.new(params[:model])

Yet, in Model, logger.info column_name shows 5
(params[:model][:column_name] = 5.6).

Any clues on how to change this?

Thanks a lot,

Mark

You should use column_name_before_type_cast reader to get raw data that user
has supplied. It is described in AR docs:

= Accessing attributes before they have been typecasted
...
This is especially useful in validation situations where the user might supply
a string for an integer field and you want to display the original string
back in an error message. Accessing the attribute normally would typecast the
string to 0, which isn’t what you want.

Thanks a lot Maxim, that's exactly what I'd missed.

Mark