Rails now has a good trick. When an error rails occurs, it places a div with the .field_with_errors class around the error fields. So now you can just target this class and add styling.
To focus on the input you can do
.field_with_errors input{ border: 1px solid red !important; }
this css will put a beautiful red line around the input element although this is important! will overwrite any existing styles.
Abhilash
source share