hi there. Here is the simple scenario:
My active record connects to a table that contains an integer field.
My form contains a text box that allows me to enter a value to get
updated to the integer field.
If anything gets entered that is anything other than a POSITIVE INTEGER,
I want to display an error.
I have noticed that if I create a new active record like
@record = MyClass.new(params[:number])
and the number is a float, say 4.06, this will get rounded in the Active
Record if i display it at this point
render_text @record.number …will show 4
Because it will get rounded automatically, I can’t tell that it is a
non-integer number from within the active record and display an error.
Also, if after submitting the form, the active record will contain the
rounded value (4) but on return to the form, the text field will contain
the original value submitted, 4.06.
How can I intervene this behaviour, ie, test weather the value submitted
is an INTEGER and return an error if it is not (including decimal
values).