mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix error_messages_for when instance variable names are given.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
e714b499cc
commit
9fbb2c571b
2 changed files with 9 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ module ActiveModel
|
|||
# it will underscore then humanize the class name (BlogPost.human_name #=> "Blog post").
|
||||
# Specify +options+ with additional translating options.
|
||||
def human(options={})
|
||||
return @human unless @klass.respond_to?(:lookup_ancestors) &&
|
||||
@klass.respond_to?(:i18n_scope)
|
||||
|
||||
defaults = @klass.lookup_ancestors.map do |klass|
|
||||
klass.model_name.underscore.to_sym
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue