ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-rails
ruby-rails
[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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved