aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-10-21 11:18:36 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-21 11:18:36 -0500
commit9fbb2c571b65e0501bf3570a3d49e553a9ae39c1 (patch)
treef67ce04a5ff9f3b32be8c1b060c4991d67ca687a /actionpack/lib/action_view/helpers
parente714b499cc1f7ebc84f8d0e96607b79e60f2828d (diff)
downloadrails-9fbb2c571b65e0501bf3570a3d49e553a9ae39c1.tar.gz
rails-9fbb2c571b65e0501bf3570a3d49e553a9ae39c1.tar.bz2
rails-9fbb2c571b65e0501bf3570a3d49e553a9ae39c1.zip
Fix error_messages_for when instance variable names are given.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/active_model_helper.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/active_model_helper.rb b/actionpack/lib/action_view/helpers/active_model_helper.rb
index 3c398fe4da..c70f29f098 100644
--- a/actionpack/lib/action_view/helpers/active_model_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_model_helper.rb
@@ -191,13 +191,13 @@ module ActionView
options = params.extract_options!.symbolize_keys
objects = Array.wrap(options.delete(:object) || params).map do |object|
- unless object.respond_to?(:to_model)
- object = instance_variable_get("@#{object}")
- object = convert_to_model(object)
- else
- object = object.to_model
- options[:object_name] ||= object.class.model_name.human
+ object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
+ object = convert_to_model(object)
+
+ if object.class.respond_to?(:model_name)
+ options[:object_name] ||= object.class.model_name.human.downcase
end
+
object
end