Displaying 1 result from an estimated 1 matches for "mailing_middle_nam".
Did you mean:
mailing_middle_name
2006 Jul 06
2
Not accepting nil values in fields when CREATING a record
...doesn''t have
any NULLs in fields.
I can''t use validates_presence_of, because it will puke if there''s an
empty string ("")
So... is there an EASY way to check if a list of fields is null?
Right now, I''m doing:
def validate()
[...]
errors.add(:mailing_middle_name, "cannot be nil") if
mailing_middle_name.nil?
errors.add(:company, "cannot be nil") if company.nil?
errors.add(:address_line_2, "cannot be nil") if
address_line_2.nil?
[...]
end
But it''s ugly.
Plus, I realise that passing "nil" is a...