Utilisation: Rails 3.0.3, Ruby 1.9.2Rails 3 I18n Traduction d'étiquettes pour nested_attributes en relation has_many
Voici la relation:
class Person < ActiveRecord::Base
has_many :contact_methods
accepts_nested_attributes_for :contact_methods
end
class ContactMethod < ActiveRecord::Base
attr_accessible :info
belongs_to :person
end
Maintenant, lorsque je tente de personnaliser les étiquettes de contact_method dans I18n , il ne le reconnaît pas.
en:
helpers:
label:
person[contact_methods_attributes]:
info: 'Custom label here'
J'ai aussi essayé:
person[contact_method_attributes]
Cela fonctionne très bien pour les relations 1-1, par exemple
person[wife_attributes]:
name: 'My wife'
mais pas person[wives_attributes]
Merci à l'avance
Dans Rails 3.2.12, je n'ai pas pu obtenir 'helpers.label.person.contact_method.info', mais: 'helpers.label.person [contact_method_attributes] .info' fait. (C'était pour has_one, je n'ai pas essayé avec la relation has_many.) – graywh
Dans Rails 3.1.10, je pouvais obtenir: 'helpers.label.person.contact_methods.info' pour travailler, mais je devais utiliser: 'helpers.label .person [contact_methods_attributes] [new_contact_methods] 'pour mon association has_many javascript-addable. (Le "new_contact_methods" est un espace réservé pour l'ID lorsque le modèle est rendu pour l'attribut de contenu de données de mon bouton qui ajoute les champs au DOM. – graywh