ruby - rails presence conditional validation between 2 fields -
first rails program here. go little further req'd and, instance, allow entries address book accept first name or last name or both. in other words, validate_presence_of first or last, , throw exception if both missing, super easy thing in c++, syntax in ruby?
couldn't run conditional validates presence of last_name if first_name blank? if first name not blank, validation won't run, if blank makes sure last_name not blank...
validates :last_name, :presence => true, :if => "first_name.blank?"
Comments
Post a Comment