In order to display an error message when there is an input error (for example, no input) in form
, it is described using the ʻerrors method`, and when the movement is confirmed, the view collapses. This is the method I solved at that time.
When I checked the collapsed view, I confirmed that the div class
called field_with_errors
gave it. This is the cause.
This time, this div class
called field_with_errors
is not assigned.
I made the following description in config / application.rb
.
module #Model name
class Application < Rails::Application
config.load_defaults 6.0
config.i18n.default_locale = :ja
config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag }
#↑ I added this description
end
end
By doing this, I was able to do without extra classes!
・ Https://yukimasablog.com/rails-field-with-errors
Recommended Posts