diff --git a/actionview/lib/action_view/helpers/tags/translator.rb b/actionview/lib/action_view/helpers/tags/translator.rb index 9cdccaf4aaa189e3f44046c257622668d3ce997f..42433caf36d6e9cc9771dcebeac28af6806f6ac2 100644 --- a/actionview/lib/action_view/helpers/tags/translator.rb +++ b/actionview/lib/action_view/helpers/tags/translator.rb @@ -2,13 +2,13 @@ module ActionView module Helpers module Tags # :nodoc: class Translator # :nodoc: - attr_reader :object, :object_name, :method_and_value, :i18n_scope + attr_reader :object_name, :method_and_value, :i18n_scope, :model def initialize(object, object_name, method_and_value, i18n_scope) - @object = object @object_name = object_name.gsub(/\[(.*)_attributes\]\[\d+\]/, '.\1') @method_and_value = method_and_value @i18n_scope = i18n_scope + @model = object.respond_to?(:to_model) ? object.to_model : object end def call @@ -30,10 +30,6 @@ def human_attribute_name model.class.human_attribute_name(method_and_value) end end - - def model - @model ||= object.to_model if object.respond_to?(:to_model) - end end end end