lib/validates_timeliness/validator.rb in adzap-validates_timeliness-2.0.0 vs lib/validates_timeliness/validator.rb in adzap-validates_timeliness-2.1.0

- old
+ new

@@ -92,11 +92,11 @@ def interpolation_values(option, restriction) format = self.class.error_value_formats[type] restriction = [restriction] unless restriction.is_a?(Array) if defined?(I18n) - message = custom_error_messages[option] || I18n.t('activerecord.errors.messages')[option] + message = I18n.t('activerecord.errors.messages')[option] subs = message.scan(/\{\{([^\}]*)\}\}/) interpolations = {} subs.each_with_index {|s, i| interpolations[s[0].to_sym] = restriction[i].strftime(format) } interpolations else @@ -116,10 +116,10 @@ end def add_error(record, attr_name, message, interpolate=nil) if defined?(I18n) custom = custom_error_messages[message] - record.errors.add(attr_name, custom || message, interpolate || {}) + record.errors.add(attr_name, message, { :default => custom }.merge(interpolate || {})) else message = error_messages[message] if message.is_a?(Symbol) message = message % interpolate record.errors.add(attr_name, message) end