diff options
author | Martin Svalin <martin@lite.nu> | 2011-10-11 21:44:22 +0200 |
---|---|---|
committer | Martin Svalin <martin@lite.nu> | 2011-10-17 09:22:08 +0200 |
commit | 180d4137ca8222cb90a285bfd60265ae93c56968 (patch) | |
tree | e130b027cbb4e308024366cc85afb9a2609c915b /activemodel/lib/active_model | |
parent | 8919a68b961e2789286a1f9e71fd1b8a9ee7d3e0 (diff) | |
download | rails-180d4137ca8222cb90a285bfd60265ae93c56968.tar.gz rails-180d4137ca8222cb90a285bfd60265ae93c56968.tar.bz2 rails-180d4137ca8222cb90a285bfd60265ae93c56968.zip |
ActiveModel::Errors#generate_message without i18n_scope, and more test cases for #add
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index d91e4a2b6a..f90030641d 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -300,13 +300,17 @@ module ActiveModel def generate_message(attribute, type = :invalid, options = {}) type = options.delete(:message) if options[:message].is_a?(Symbol) - defaults = @base.class.lookup_ancestors.map do |klass| - [ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.attributes.#{attribute}.#{type}", - :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.#{type}" ] + if @base.class.respond_to?(:i18n_scope) + defaults = @base.class.lookup_ancestors.map do |klass| + [ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.attributes.#{attribute}.#{type}", + :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.#{type}" ] + end + else + defaults = [] end defaults << options.delete(:message) - defaults << :"#{@base.class.i18n_scope}.errors.messages.#{type}" + defaults << :"#{@base.class.i18n_scope}.errors.messages.#{type}" if @base.class.respond_to?(:i18n_scope) defaults << :"errors.attributes.#{attribute}.#{type}" defaults << :"errors.messages.#{type}" |