Rails I18n accepts_nested_attributes_for and error_messages_for

后端 未结 2 1085
谎友^
谎友^ 2020-12-08 16:39

I\'ve got two models

class SurveyResponse
  has_many :answers, :class_name => SurveyResponseAnswer.name
  accepts_nested_attributes_for :answers
end

clas         


        
2条回答
  •  失恋的感觉
    2020-12-08 16:44

    As of Rails 3.2.0, the i18n yaml has changed to

    en: 
      activerecord:
        attributes:
          survey_response:
            foo: "Foo"
          survey_response/answers:
            answer_text: "Response"
    

    (Note the slash.) This also permits you to define an attribute name on the collection itself, e.g.

    en: 
      activerecord:
        attributes:
          survey_response:
            foo: "Foo"
            answers: "Ripostes"
          survey_response/answers:
            answer_text: "Response"
    

    Source: https://github.com/rails/rails/pull/3859

提交回复
热议问题