Permalink
Browse files

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>
  • Loading branch information...
1 parent 45b0e31 commit 6e67b49ff8584da5ae58fa7cf75d62b1cc328091 Dustin Anderson committed with technoweenie Feb 12, 2009
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/technoweenie/attachment_fu.rb
@@ -422,7 +422,11 @@ def set_size_from_temp_path
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

0 comments on commit 6e67b49

Please sign in to comment.