field_with_errorsクラスとは?
Railsのバリデーションでエラーになった箇所に付与されるクラスの事です。

Bootstrap3
- field_with_errorsクラスに対して Bootstrap3の
.has-errorをextendすることで入力欄が赤枠で表示されていた。
application.scss
.field_with_errors {
@extend .has-error;
}
Bootstrap4
-
.has-errorが無くなっているのでextendできない。 - 代わりに
inputタグに対して.is-invalidをextendする。
application.scss
.field_with_errors {
input {
@extend .is-invalid;
}
}