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:
Родитель
45b0e31c89
Коммит
6e67b49ff8
|
@ -422,9 +422,13 @@ module Technoweenie # :nodoc:
|
|||
def attachment_attributes_valid?
|
||||
[:size, :content_type].each do |attr_name|
|
||||
enum = attachment_options[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
|
||||
|
||||
# Initializes a new thumbnail with the given suffix.
|
||||
def find_or_initialize_thumbnail(file_name_suffix)
|
||||
|
|
Загрузка…
Ссылка в новой задаче