I've got two models
class SurveyResponse
has_many :answers, :class_name => SurveyResponseAnswer.name
accepts_nested_attributes_for :answers
end
class SurveyResponseAnswer
belongs_to :survey_response
validates_presence_of :answer_text
end
In my nested form if validation fails I get this error displayed on the screen:
"answers answer text can't be blank"
I've customized my attribute names somewhat successfully using rails I18n. It doesn't behave exactly how I would expect though. The yml file below doesn't affect how the attribute name is printed in error_messages_for
en:
activerecord:
models:
survey_response:
answers: "Response"
But if from script/console I try
SurveyResponse.human_attribute_name("answers")
I get the expected result of "Response".
What I'd like to do is have the validation error message say:
"Response answer text can't be blank". Any ideas what I need to fix?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…