aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSven Fuchs <svenfuchs@artweb-design.de>2008-07-06 21:20:02 +0200
committerSven Fuchs <svenfuchs@artweb-design.de>2008-07-06 21:20:02 +0200
commit84816ae981a8598e5e401eb1b9b805de840fefc9 (patch)
tree8b995401f92c8dcd8c53e3f332687219480e4def /activerecord
parentc9ed2c9bd24b9f4cdfcb692151f87ba900469e71 (diff)
downloadrails-84816ae981a8598e5e401eb1b9b805de840fefc9.tar.gz
rails-84816ae981a8598e5e401eb1b9b805de840fefc9.tar.bz2
rails-84816ae981a8598e5e401eb1b9b805de840fefc9.zip
align with changes in i18n
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/validations.rb5
-rw-r--r--activerecord/test/cases/validations_i18n_test.rb6
2 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 8ba09b3992..a328c4d927 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -70,7 +70,7 @@ module ActiveRecord
msgs << options[:default] if options[:default]
msgs << key
- I18n.t options.merge(:default => msgs, :scope => [:active_record, :error_messages])
+ I18n.t nil, options.merge(:default => msgs, :scope => [:active_record, :error_messages])
end
# Returns true if the specified +attribute+ has errors associated with it.
@@ -158,7 +158,6 @@ module ActiveRecord
# ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Address can't be blank"]
def full_messages(options = {})
full_messages = []
- locale = options[:locale]
@errors.each_key do |attr|
@errors[attr].each do |message|
@@ -168,7 +167,7 @@ module ActiveRecord
full_messages << message
else
key = :"active_record.human_attribute_names.#{@base.class.name.underscore.to_sym}.#{attr}"
- attr_name = I18n.translate(key, locale, :default => @base.class.human_attribute_name(attr))
+ attr_name = I18n.translate(key, :locale => options[:locale], :default => @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 5be518c547..86834fe920 100644
--- a/activerecord/test/cases/validations_i18n_test.rb
+++ b/activerecord/test/cases/validations_i18n_test.rb
@@ -46,14 +46,14 @@ class ActiveRecordValidationsI18nTests < Test::Unit::TestCase
global_scope = [:active_record, :error_messages]
custom_scope = global_scope + [:custom, 'topic', :title]
- I18n.expects(:t).with :scope => [:active_record, :error_messages], :default => [:"custom.topic.title.invalid", 'default from class def', :invalid]
+ I18n.expects(:t).with nil, :scope => [:active_record, :error_messages], :default => [:"custom.topic.title.invalid", 'default from class def', :invalid]
@topic.errors.generate_message :title, :invalid, :default => 'default from class def'
end
def test_errors_generate_message_translates_custom_model_attribute_keys_with_sti
custom_scope = [:active_record, :error_messages, :custom, 'topic', :title]
- I18n.expects(:t).with :scope => [:active_record, :error_messages], :default => [:"custom.reply.title.invalid", :"custom.topic.title.invalid", 'default from class def', :invalid]
+ I18n.expects(:t).with nil, :scope => [:active_record, :error_messages], :default => [:"custom.reply.title.invalid", :"custom.topic.title.invalid", 'default from class def', :invalid]
Reply.new.errors.generate_message :title, :invalid, :default => 'default from class def'
end
@@ -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', :default => 'Title').returns('Title')
+ I18n.expects(:translate).with(:"active_record.human_attribute_names.topic.title", :locale => 'en-US', :default => 'Title').returns('Title')
@topic.errors.full_messages :locale => 'en-US'
end
end