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
+3
View File
@@ -79,6 +79,9 @@ en:
visitors_this_month: This month's visitors
visitors_this_year: This year's visitors
errors:
at_least_one: must at least have one value
admin:
access:
denied:
+3
View File
@@ -77,6 +77,9 @@ zh_tw:
visitors_this_month: 本月造訪
visitors_this_year: 今年造訪
errors:
at_least_one: 必須至少有一個值
admin:
access:
denied: