내가 가지고 예를 들어, I 필드에 오류 메시지를 추가 해요 간단한 조건에 따라 낮은 수준 validate_on_create
방법을 사용하는 모델,레일 : form.error_messages가 fieldWithErrors에서 사용자 정의 검증 필드를 포장하지 않습니다는
self.errors.add(:expiry_date, "is too soon") if self.expiry_date && self.expiry_date < Date.today + 1.week
저장을 실패한 후 'new'보기를 렌더링 할 때 예상대로 필드가 error_messages_for
에 의해 선택되지 않습니다. 유효성 검사가 올바르게 작동하고 있음을 나타내는 오류의 ususal 목록에 오류가 표시됩니다.
왜 이것이 사람인지 전혀 알지 못합니까? 나는 form.error_messages
이 물체의 모든 오류를보고 있지 않다고 생각하니?
<% form_for([:solicitor, @policy]) do |form| %>
<%= form.error_messages :message => "See the list of reasons below to find out why not:", :header_message => "Sorry but we cannot yet create your policy based on the information you've provided." %>
<%= render :partial => 'form', :locals => {:form => form} %>
<% end %>
form_for 및 form.error_messages보기 코드를 보겠습니다. –
방금 코드를 추가했습니다. – tsdbrown