summaryrefslogtreecommitdiffstats
path: root/config/initializers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-22 14:46:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-22 14:46:32 +0000
commita64b8695c8c29d390693e86b8d7497e4579936a3 (patch)
treeee7080e3741e41513f8a86718a565c0f1d5aa17c /config/initializers
parent67fd5f3dc92963a0572dd5511cbe19c7c04141f0 (diff)
downloadredmine-a64b8695c8c29d390693e86b8d7497e4579936a3.tar.gz
redmine-a64b8695c8c29d390693e86b8d7497e4579936a3.zip
Patch ActiveRecord::Errors#full_messages so that it contains custom values error messages.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2518 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/10-patches.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb
index 5d19a6fc0..f4ae06cd6 100644
--- a/config/initializers/10-patches.rb
+++ b/config/initializers/10-patches.rb
@@ -12,6 +12,36 @@ module ActiveRecord
end
end
+module ActiveRecord
+ class Errors
+ def full_messages(options = {})
+ full_messages = []
+
+ @errors.each_key do |attr|
+ @errors[attr].each do |message|
+ next unless message
+
+ if attr == "base"
+ full_messages << message
+ elsif attr == "custom_values"
+ # Replace the generic "custom values is invalid"
+ # with the errors on custom values
+ @base.custom_values.each do |value|
+ value.errors.each do |attr, msg|
+ full_messages << value.custom_field.name + ' ' + msg
+ end
+ end
+ else
+ attr_name = @base.class.human_attribute_name(attr)
+ full_messages << attr_name + ' ' + message
+ end
+ end
+ end
+ full_messages
+ end
+ end
+end
+
module ActionView
module Helpers
module DateHelper