Forum: Ruby on Rails is there a "validates_empty" method or a way to do this in a single line?

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.
Greg H. (Guest)
on 2008-11-10 23:32
(Received via mailing list)
Hi,

re Model validations:  is there a "validates_empty" method or a way to
do this in a single line?

tks
Mark T. (Guest)
on 2008-11-11 00:07
(Received via mailing list)
Hmm... maybe validates_length_of with max set to 0 (and a custom
message)

Otherwise you may have to write your own validator using a callback
like before_create or before_validation_on_create.

-- Mark.
This topic is locked and can not be replied to.