8 lines
224 B
Ruby
8 lines
224 B
Ruby
class NotNilValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
if value.nil?
|
|
record.errors.add attribute, (options[:message] || "#{attribute} should not be nil")
|
|
end
|
|
end
|
|
end
|