diff options
author | Alexander Uvarov <alexander.uvarov@gmail.com> | 2011-11-17 12:04:46 +0600 |
---|---|---|
committer | Alexander Uvarov <alexander.uvarov@gmail.com> | 2011-11-17 12:37:00 +0600 |
commit | c2b6f63bbe2740fd63a36eeefe17d51813a17324 (patch) | |
tree | eaca3015f757a56df02351fae4054b113c0c8e5b /actionpack/lib/action_view | |
parent | e3671422556ac61f39539264713ba9c04814b80f (diff) | |
download | rails-c2b6f63bbe2740fd63a36eeefe17d51813a17324.tar.gz rails-c2b6f63bbe2740fd63a36eeefe17d51813a17324.tar.bz2 rails-c2b6f63bbe2740fd63a36eeefe17d51813a17324.zip |
Fix impractical I18n lookup in nested fields_for
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index f148ffbd73..d687866d0d 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -995,8 +995,16 @@ module ActionView label_tag(name_and_id["id"], options, &block) else content = if text.blank? + object_name.gsub!(/\[(.*)_attributes\]\[\d\]/, '.\1') method_and_value = tag_value.present? ? "#{method_name}.#{tag_value}" : method_name - I18n.t("helpers.label.#{object_name}.#{method_and_value}", :default => "").presence + + if object.respond_to?(:to_model) + key = object.class.model_name.i18n_key + i18n_default = ["#{key}.#{method_and_value}".to_sym, ""] + end + + i18n_default ||= "" + I18n.t("#{object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.label").presence else text.to_s end |