A model has only one column, a numeric and the class definition has no
create_table "examples"do |t|
in IRB I create a row, save it, and then attempt to assign “abcd” to
the attribute. Clearly this is wrong, and in fact the assignment does
not take place. I would like however to trap this error, which I
cannot seem to do. Example below:
Thanks Sean, I understand that and do it. Just surprised to find that
the actual assignmnent doesn’t fail, and does return the bogus value
as the result of the assignment.
So to error processing: my validation message string is:
“Must be a number between -180 and 180, not
However it appears that the *_before_type_cast methods (indeed any
attribute methods) aren’t available in the scope of validations. Any
ideas how to access these methods in the message string? Or
alternative suggestions on how to achieve the objective of having a
meaningful message including the wrong text?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.