Add custom validator and fix .html_safe with rescue

This commit is contained in:
Christophe Vilayphiou committed 2012-07-31 14:25:46 +08:00
1 parent ecb75fd085
commit 9f859b903d
16 files changed
+32 -16

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
class AtLeastOneValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || I18n.t("errors.at_least_one")) if (value.blank? || value.values.join.eql?(''))
end
end