[Rails] What to do when the view collapses when a message is displayed with the errors method

Introduction

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.

Cause

When I checked the collapsed view, I confirmed that the div class called field_with_errors gave it. This is the cause.

Coping

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!

reference

・ Https://yukimasablog.com/rails-field-with-errors

Recommended Posts

[Rails] What to do when the view collapses when a message is displayed with the errors method
[Rails] What to do if you can't get an error message with the errors method
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
[IOS] What to do when the image is filled with one color
What to do when rails creates a 〇〇 2.rb file
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do when is invalid because it does not start with a'-'
[Rails] What to do when the Refile image is not displayed when writing the processing at the time of Routing Error
What to do if you get an "A server is already running." Error when you try to start the rails server
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do when Address already in use is displayed after executing rails s
A warning is displayed when trying to use a huge integer with the special variables $ 1, $ 2, $ 3 ...
What to do when you launch an application with rails
[Ruby / Rails] What to do when NoMethodError appears when using a destructive method such as filter!
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What to do if Cloud9 is full in the Rails tutorial
How to write the view when Vue is introduced in Rails?
What to do when a javax.el.PropertyNotWritableException occurs
What to do when you want to know the source position where the method is defined in binding.pry
Notes on what to do when EC2 is set up with t2.micro
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
What to do if zip dies if there is a pom when making an executable jar with gradle
[Rails / Docker] What to do if access is denied by the browser (localhost: 3000) after adding a gem
What to do when you want to delete a migration file that is "NO FILE"
What to do when rails db: seed does not reflect in the database
[Rails] When transitioning to a page with link_to, move to the specified location on the page
What to do about "A server is already running ..." that happened without turning off the rails server in the terminal
What to do if the Rails server can't start
What to do when The SSL certificate has expired
What to do when a null byte error occurs
ParseException: What to do when Unparseable date is reached
A memo to do for the time being when building CentOS 6 series with VirtualBox
[Rails] How to solve the error "undefined method` visit'" when using Capybara with Rspec
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
[Joke] What to do when the invalid sample rate is reached when using Mixxx on Ubuntu 20.04
What is the pluck method?
What to do when Method not found in f: ajax
What to do if FacesMessage is set but not displayed
[Rails] What to do when rails db: migrate cannot be done because there is no table referenced by the foreign key
What to do when Cannot apply expression operators to method binding
What to do when Rails on Docker does not reflect controller changes in the browser
What to do if you can't use the rails command
What is the initialize method?
[Rails 6] What to do when a missing a template error occurs after introducing haml [Super easy]
Session was a cookie designed to be erased when the browser was closed and was a method for exchanging it: Rails Tutorial Note-What is a Rails Session?
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
[Programming beginner] What to do when rails s becomes an error in the local development environment
What to do when Gradle says "For more information, please recompile with the -Xlint: unchecked option"
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
How to build an environment with Docker, which is the minimum required to start a Rails application
When a beginner makes a personal app with rails, the procedure to bring it to the starting point anyway.
[Java] What to do if a lot of "File is opened too much" is displayed due to FileNotFoundException
What to do about the "cannot be read or is not a valid ZIP file" error
What to do when Maven says "For more information, please recompile with the -Xlint: unchecked option"
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
What to do if validation doesn't work with the update action
[Rails] What to do if data is not registered in DB
What to do when the changes in the Servlet are not reflected
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2