Rails I18n accepts_nested_attributes_for and error_messages_for

后端 未结 2 1091
谎友^
谎友^ 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:45

    Try this:

    en: 
      activerecord:
        models:
          survey_response:
            answers:
              answer_text: "Response"
    

    I am using Rails 3 and this is working for me (my i18n file is a bit different, using "attributes" instead of models. I don't know if this works in 2.3)

    en: 
      activerecord:
        attributes:
          survey_response:
            answers:
              answer_text: "Response"
    

    Before that I was trying to create a attribute in the yml called "answers_answer_text" but it was not working.

    I hope this solves your issue.

提交回复
热议问题