Reputation: 12378
I have strings to store in the database, and I want to accept empty strings, but not null values. This is why I can't use the rails presence validator.
I've read an answer to this question for rails 3 from here, but I wasn't sure if that answer also applied to rails 4. Is there anything in rails 4 that might solve this issue?
Upvotes: 1
Views: 77
Reputation: 3866
I think, it should work for Rails 4 as well. Try this:
validates :email, presence: {allow_blank: true, allow_nil: false }
Thanks
Upvotes: 1