One tweak to support Rails 2.2 I18n validation error message (due to deprecated ActiveRecord::Errors.default_error_messages) - Tests were getting very ugly with all the deprec warning messages

Signed-off-by: rick <technoweenie@gmail.com>
This commit is contained in:
Dustin Anderson 2009-02-13 04:43:45 +08:00 коммит произвёл rick
Родитель 45b0e31c89
Коммит 6e67b49ff8
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -422,7 +422,11 @@ module Technoweenie # :nodoc:
def attachment_attributes_valid?
[:size, :content_type].each do |attr_name|
enum = attachment_options[attr_name]
errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))
if Object.const_defined?(:I18n) # Rails >= 2.2
I18n.translate("activerecord.errors.messages.inclusion", attr_name => enum)
else
errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))
end
end
end