I got the following error while implementing the user management function.
ActiveRecord::NotNullViolation in Devise::RegistrationsController#create
If you look it up on a reference site
"This error is an error caused by saving an item that should not be NULL due to DB constraints."
There was.
In the image error statement above
Mysql2::Error: Field 'prefecture_address' doesn't have a default value
So I checked the migration file to confirm this. Please see the image.
There seems to be no problem here because it is set like that in the migration file.
If it is set in the migration file, I think that the recipient may not have received it, so next check the controller. This was also the column name as specified in the migration file.
Now that I have migrated and controllered, I decided to check the view. (I'm a little impatient here.) The image of the view is as follows. Did you understand ... In the migration file and controller, it was prefecture_address, but in the view file, it was prefecture_address.
When I finished modifying the view and made a new registration, I was able to register successfully.
Basically, when I get an error, I'm impatient with NoRoute Matches (I think I've overcome NoRoute Matches), so when I got an error I've never seen before, I thought, "Oh ... it's over ...". In this case, I didn't know which file the source code was referring to, so I wasn't rushed.
I was lucky to look into the error and hit the site. I will take this opportunity to add error tolerance. Excuse me.
【teratail】 Error when logging in / creating a new one by introducing the devise function https://teratail.com/questions/235508