[RAILS] When an error occurs even though validation is not set

Why

ActiveRecord::RecordInvalid:Validation failed

No matter where you check the model or the migration file There is no validation setting.

However, the error that keeps appearing.

Cause

It seems that the change from Rails 5 has set the validation of existence in belongs_to.

So change as follows

belongs_to :post_id, optional: true

reference

https://railsguides.jp/association_basics.html

https://teratail.com/questions/65278

Recommended Posts

When an error occurs even though validation is not set
When submitting form, no error message is displayed even though validation failed
An error occurs when codedeploy-agent is installed in Ubuntu Server 20.04
A reminder when an aapt.exe error occurs
How to set when "The constructor Empty () is not visible" occurs in junit
The story when the container does not start up with docker-compose up and an error occurs
Customize the display when an error such as 404 Not Found occurs in Spring Boot
[Memorandum] What is an error?
"tx" is not bound error
The idea of cutting off when the error is not resolved
"Error: Main class XXX not found or could not be loaded" occurs even though the main class exists
Collecting client information when an error occurs in a web application
Solution notes when an error occurs when downloading docker gpg using curl
About error when implementing spring validation
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if an error occurs when nokogiri enters when bundle install
[Error] Regarding rbenv: ruby 2.5.1 is not installed ot ~ when executing automatic deployment
[Ruby On Rails] When a model unit test is performed with RSpec using FactoryBot, an error occurs because the foreign key is not entered.
If the JDK version is correct in Eclipse but an error occurs or the compiler does not work properly
[Rails] Annotate is not executed when migrating
Error in implementation when implementing Spring validation
When UITextView is not displayed (Swift, Xcode)
Add if not in Set, error message if
What is Ruby's attr_accessor?
What is an interface?
What is Ruby's self?
What is an initializer?
What is an operator?
Yarn is not installed
What is an annotation?
When an error occurs even though validation is not set
[Memorandum] What is an error?
"tx" is not bound error
Ruby # {} is not variable expansion
What exactly is an API?
[Ruby] What is an instance?
Is it an Android app?
[Rails] fields_for is not displayed
Arrays.binarySearch is an exact match
[Error resolution] Occurs when trying to build an environment for spring with docker
[Heroku] How to solve when an error is displayed on git push heroku master
Send an email when an ERROR level log occurs with the logback SMTP Appender
When using a list in Java, java.awt.List comes out and an error occurs