[Rails] Using validation helpers for custom validation
by Derek Haynes other posts by this author
Sep 9 2005 5:45AM messages near this date
[Rails] Assets and FastCGI
|
Re: [Rails] Using validation helpers for custom validation
I'd like to validate that the length of text is within a specified
range, but only if the text is not nil.
To do this, I'd like to setup a custom validation:
def validate_on_update
validate_within_range_if_not_nil
end
Where validate_within_range_if_not_nil would first check if the text
is nil, and if not, then use the validation helper
#validates_length_of.
However, I don't know how to call this method from within a custom
validation method. I tried:
ActiveRecord::Validations::ClassMethods::validates_length_of
But received a NoMethodError.
Any ideas on implementing this type of validation?
--
Derek Haynes
HighGroove Studios - http://www.highgroove.com
Keeping it Simple.
404.593.4879
_______________________________________________
Rails mailing list
Rails@[...].org
http://lists.rubyonrails.org/mailman/listinfo/rails
Thread:
Derek Haynes
Elliot Bowes
Derek Haynes
Michael King
|