aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorIain Hecker <github@iain.nl>2008-08-16 21:45:23 +0200
committerSven Fuchs <svenfuchs@artweb-design.de>2008-08-20 17:41:43 +0200
commite2b191681e1c8c8b4344f1fc755e48fccdd1d603 (patch)
tree3ceb26919e5da195fefc88dae4f88e87a395d02a /activerecord/lib/active_record
parentc531248938302477c5e52138d59a6c3d1527d963 (diff)
downloadrails-e2b191681e1c8c8b4344f1fc755e48fccdd1d603.tar.gz
rails-e2b191681e1c8c8b4344f1fc755e48fccdd1d603.tar.bz2
rails-e2b191681e1c8c8b4344f1fc755e48fccdd1d603.zip
Added :value as interpolation variable available to error messages
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/validations.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 040681a09c..a442d008a9 100644
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -92,17 +92,19 @@ module ActiveRecord
:"custom.#{klass.name.underscore}.#{message}" ]
end
- defaults << options[:default] if options[:default]
- defaults.flatten! << message
+ defaults << options.delete(:default)
+ defaults = defaults.compact.flatten << message
model_name = @base.class.name
key = defaults.shift
-
- options.merge!({
- :default => defaults,
- :model => @base.class.human_name,
- :attribute => @base.class.human_attribute_name(attribute.to_s),
- :scope => [:activerecord, :errors, :messages] })
+ value = @base.send(attribute) if @base.respond_to?(attribute)
+
+ options = { :default => defaults,
+ :model => @base.class.human_name,
+ :attribute => @base.class.human_attribute_name(attribute.to_s),
+ :value => value,
+ :scope => [:activerecord, :errors, :messages]
+ }.merge(options)
I18n.translate(key, options)
end