diff options
author | Iain Hecker <github@iain.nl> | 2008-08-31 12:14:24 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-31 13:24:08 -0700 |
commit | 76797b443929005f43512a147e97f02f3145ed81 (patch) | |
tree | 43b6b5ed600a1d547dc939529d3a575fd5109c3c /activerecord/lib/active_record | |
parent | a1eb4e11c2cccb91483fa15f1a1a0b2ae518d2cf (diff) | |
download | rails-76797b443929005f43512a147e97f02f3145ed81.tar.gz rails-76797b443929005f43512a147e97f02f3145ed81.tar.bz2 rails-76797b443929005f43512a147e97f02f3145ed81.zip |
translates when a message symbol has been set on builtin validations
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 9ee80e6655..dae4ae8122 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -87,6 +87,8 @@ module ActiveRecord # </ol> def generate_message(attribute, message = :invalid, options = {}) + message, options[:default] = options[:default], message if options[:default].is_a?(Symbol) + defaults = @base.class.self_and_descendents_from_active_record.map do |klass| [ :"models.#{klass.name.underscore}.attributes.#{attribute}.#{message}", :"models.#{klass.name.underscore}.#{message}" ] @@ -95,7 +97,6 @@ module ActiveRecord defaults << options.delete(:default) defaults = defaults.compact.flatten << :"messages.#{message}" - model_name = @base.class.name key = defaults.shift value = @base.respond_to?(attribute) ? @base.send(attribute) : nil |