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?
Try this:
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)
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.