diff options
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/validations_i18n_test.rb | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 5bbd10394c..5245f65869 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -22,7 +22,7 @@ module ActiveRecord class << self def default_error_messages ActiveSupport::Deprecation.warn("ActiveRecord::Errors.default_error_messages has been deprecated. Please use 'active_record.error_messages'.t.") - 'active_record.error_messages'.t + I18n.translate 'active_record.error_messages' end end @@ -43,7 +43,7 @@ module ActiveRecord # error can be added to the same +attribute+ in which case an array will be returned on a call to <tt>on(attribute)</tt>. # If no +msg+ is supplied, "invalid" is assumed. def add(attribute, message = nil) - message ||= :"active_record.error_messages.invalid".t + message ||= I18n.translate :"active_record.error_messages.invalid" @errors[attribute.to_s] ||= [] @errors[attribute.to_s] << message end @@ -168,7 +168,7 @@ module ActiveRecord full_messages << message else key = :"active_record.human_attribute_names.#{@base.class.name.underscore.to_sym}.#{attr}" - attr_name = key.t(locale) || @base.class.human_attribute_name(attr) + attr_name = I18n.translate(key, locale, :raise => true) rescue @base.class.human_attribute_name(attr) full_messages << attr_name + " " + message end end diff --git a/activerecord/test/cases/validations_i18n_test.rb b/activerecord/test/cases/validations_i18n_test.rb index 53e90f4d53..840fcd81d0 100644 --- a/activerecord/test/cases/validations_i18n_test.rb +++ b/activerecord/test/cases/validations_i18n_test.rb @@ -79,7 +79,7 @@ class ActiveRecordValidationsI18nTests < Test::Unit::TestCase def test_errors_full_messages_translates_human_attribute_name_for_model_attributes @topic.errors.instance_variable_set :@errors, { 'title' => 'empty' } - I18n.expects(:translate).with(:"active_record.human_attribute_names.topic.title", 'en-US').returns('Title') + I18n.expects(:translate).with(:"active_record.human_attribute_names.topic.title", 'en-US', :raise => true).returns('Title') @topic.errors.full_messages :locale => 'en-US' end end |