aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-30 13:07:48 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-30 13:12:12 +0100
commitd6e2f5013cdc0aa830d167a84582f48dc636dc81 (patch)
treeff2f5726ad2a452a768fc551571ed3e09a80d1e6 /activerecord
parent431fc3c81735f8873e52f4a1942a5ac761d18cc9 (diff)
downloadrails-d6e2f5013cdc0aa830d167a84582f48dc636dc81.tar.gz
rails-d6e2f5013cdc0aa830d167a84582f48dc636dc81.tar.bz2
rails-d6e2f5013cdc0aa830d167a84582f48dc636dc81.zip
Drop AR I18n deprecation and simple use errors.messages as fallback.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/locale/en.yml24
-rw-r--r--activerecord/lib/active_record/railtie.rb12
-rw-r--r--activerecord/lib/active_record/validations.rb4
-rw-r--r--activerecord/test/cases/autosave_association_test.rb4
-rw-r--r--activerecord/test/cases/validations/i18n_validation_test.rb14
5 files changed, 23 insertions, 35 deletions
diff --git a/activerecord/lib/active_record/locale/en.yml b/activerecord/lib/active_record/locale/en.yml
index 4115cc8e17..810359fef3 100644
--- a/activerecord/lib/active_record/locale/en.yml
+++ b/activerecord/lib/active_record/locale/en.yml
@@ -1,9 +1,16 @@
en:
- errors:
- messages:
- taken: "has already been taken"
- record_invalid: "Validation failed: {{errors}}"
- # Append your own errors here or at the model/attributes scope.
+ # Attributes names common to most models
+ #attributes:
+ #created_at: "Created at"
+ #updated_at: "Updated at"
+
+ # ActiveRecord models configuration
+ activerecord:
+ errors:
+ messages:
+ taken: "has already been taken"
+ record_invalid: "Validation failed: {{errors}}"
+ # Append your own errors here or at the model/attributes scope.
# You can define own errors for models or model attributes.
# The values :model, :attribute and :value are always available for interpolation.
@@ -19,13 +26,6 @@ en:
# custom blank validation message for login attribute of User model.
#models:
- # Attributes names common to most models
- #attributes:
- #created_at: "Created at"
- #updated_at: "Updated at"
-
- # ActiveRecord models configuration
- #activerecord:
# Translate model names. Used in Model.human_name().
#models:
# For example,
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb
index 30da494d57..2b204043b4 100644
--- a/activerecord/lib/active_record/railtie.rb
+++ b/activerecord/lib/active_record/railtie.rb
@@ -77,17 +77,5 @@ module ActiveRecord
end
end
end
-
- initializer "active_record.i18n_deprecation" do
- require 'active_support/i18n'
-
- begin
- I18n.t(:"activerecord.errors", :raise => true)
- warn "[DEPRECATION] \"activerecord.errors\" namespace is deprecated in I18n " <<
- "yml files, please use just \"errors\" instead."
- rescue Exception => e
- # No message then.
- end
- end
end
end
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index a9743aa1ea..8b266be638 100644
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -10,8 +10,8 @@ module ActiveRecord
attr_reader :record
def initialize(record)
@record = record
- errors = @record.errors.full_messages.join(I18n.t('support.array.words_connector', :default => ', '))
- super(I18n.t('errors.messages.record_invalid', :errors => errors))
+ errors = @record.errors.full_messages.join(", ")
+ super(I18n.t("activerecord.errors.messages.record_invalid", :errors => errors))
end
end
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index cc5460ddb7..2995cc6f72 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -1002,9 +1002,9 @@ module AutosaveAssociationOnACollectionAssociationTests
end
def test_should_default_invalid_error_from_i18n
- I18n.backend.store_translations(:en, :errors => { :models =>
+ I18n.backend.store_translations(:en, :activerecord => {:errors => { :models =>
{ @association_name.to_s.singularize.to_sym => { :blank => "cannot be blank" } }
- })
+ }})
@pirate.send(@association_name).build(:name => '')
diff --git a/activerecord/test/cases/validations/i18n_validation_test.rb b/activerecord/test/cases/validations/i18n_validation_test.rb
index 5dfbb1516f..a0ff35f948 100644
--- a/activerecord/test/cases/validations/i18n_validation_test.rb
+++ b/activerecord/test/cases/validations/i18n_validation_test.rb
@@ -50,8 +50,8 @@ class I18nValidationTest < ActiveRecord::TestCase
# validates_uniqueness_of w/o mocha
def test_validates_associated_finds_custom_model_key_translation
- I18n.backend.store_translations 'en', :errors => {:models => {:topic => {:attributes => {:title => {:taken => 'custom message'}}}}}
- I18n.backend.store_translations 'en', :errors => {:messages => {:taken => 'global message'}}
+ I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:title => {:taken => 'custom message'}}}}}}
+ I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:taken => 'global message'}}}
Topic.validates_uniqueness_of :title
unique_topic.valid?
@@ -59,7 +59,7 @@ class I18nValidationTest < ActiveRecord::TestCase
end
def test_validates_associated_finds_global_default_translation
- I18n.backend.store_translations 'en', :errors => {:messages => {:taken => 'global message'}}
+ I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:taken => 'global message'}}}
Topic.validates_uniqueness_of :title
unique_topic.valid?
@@ -83,16 +83,16 @@ class I18nValidationTest < ActiveRecord::TestCase
# validates_associated w/o mocha
def test_validates_associated_finds_custom_model_key_translation
- I18n.backend.store_translations 'en', :errors => {:models => {:topic => {:attributes => {:replies => {:invalid => 'custom message'}}}}}
- I18n.backend.store_translations 'en', :errors => {:messages => {:invalid => 'global message'}}
+ I18n.backend.store_translations 'en', :activerecord => {:errors => {:models => {:topic => {:attributes => {:replies => {:invalid => 'custom message'}}}}}}
+ I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:invalid => 'global message'}}}
Topic.validates_associated :replies
replied_topic.valid?
- assert_equal ['custom message'], replied_topic.errors[:replies]
+ assert_equal ['custom message'], replied_topic.errors[:replies].uniq
end
def test_validates_associated_finds_global_default_translation
- I18n.backend.store_translations 'en', :errors => {:messages => {:invalid => 'global message'}}
+ I18n.backend.store_translations 'en', :activerecord => {:errors => {:messages => {:invalid => 'global message'}}}
Topic.validates_associated :replies
replied_topic.valid?