I'm trying to understand how I can achieve this. Can anyone advise me or point me in the right direction?
What I currently do, which is shown in the code snippet below, allows me to display 1 error from each field at a time. It’s not not quite exactly what I want to do.
I want to display 1 error message at a time. For example, “first name can't be blank”, then once that error has been resolved, the next error in the array of errors should be displayed. This should keep happening until all errors have been resolved.
<% @user.errors.each do |attr, msg| %>
<%= "#{attr} #{msg}" if @user.errors[attr].first == msg %>
<% end %>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…