Forum: Ruby on Rails _before_type_cast woes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hendie D. (Guest)
on 2005-11-23 17:26
(Received via mailing list)
I introduced a transient attribute to my model to capture something
that's not in the model. I added an

attr_accessor :attr

line for it in the model, and manage to do a few validates_* checks on
it successfully ... BUT as soon as I add validates_numericality, I get
an error

attr_before_type_cast method not found (or something close to that)

I assume it has something to do with the following line in
validates_numericality:

record.errors.add(attr_name, configuration[:message]) unless
record.send("#{attr_name}_before_type_cast").to_s =~ /^[+-]?\d+$/

My question is, how to do this kind of validation (or any other that
may rely on _before_type_cast) on a non-model attribute ?
This topic is locked and can not be replied to.