Reputation: 119
I have a form where I have added some validation, I would like the errors to be listed, I have an idea that it can be done this way.
= simple_form_for(@post) do |f|
.row.pt-4
.col-lg-3
-if f.object.errors[:base].present?
.alert.alert-danger
%ul
%li= f.error_notification message: f.object.errors[:base].to_sentence
The problem I have is that the first error is listing it correctly, but the others are not.
it should be displayed every error with a bullet point
Upvotes: 0
Views: 320
Reputation: 4686
You need to loop over the errors:
= simple_form_for(@post) do |f|
.row.pt-4
.col-lg-3
-if f.object.errors.any?
.alert.alert-danger
%ul
= f.object.errors.each do |error|
%li= f.error_notification message: error.message
Upvotes: 1