Reputation: 63
def names
if first_name.nil? && last_name.nil?
errors.add(:first_name, "First Name and Last Name both can't be empty!")
end
end
and even if I write so, it should allow either first or last name to be nil but not both. It doesn't work as expected
Upvotes: 0
Views: 206
Reputation: 275
Use blank?
or present?
methods instead of nil?
, they both check for empty strings and nil
's
Upvotes: 4