I've summarized what I tried when Annotate couldn't be executed and the comment wasn't written out.
It is a gem that comments the information written in the schema to the beginning of the file with the routing information. You can save the trouble of checking column information and routing. For the introduction and detailed usage, refer to the following. [Rails] How to use annotation
Annotate was executed during migration, and even though it was set to be commented on model, there was a problem that it was not executed. When I created the first migration file in the working branch and migrated, the comment was written out, but when I created the second migration file in the working branch and migrated, the comment was written out. did not.
I tried various things, but in the end I deleted the comment once and then migrated it, and it worked.
Check the Annotate setting in lib / tasks / auto_annotate_models.rake
generated by $ bundle exec rails g annotate: install
.
auto_annotate_models.rake
'skip_on_db_migrate' => 'false',
Since it is false
, it is set to write comments at the time of migrate. (No problem here)
Since it is not executed at the time of migarate, execute Annotate manually. The comment is still not written out. ..
.bash
$ bundle exec annoatate --models
If the comment is still not written, re-install the gem. In some cases, it was fixed by reinstalling.
In my case, the comment was not written out after trying various things, so I decided to delete the comment.
.bash
$ bundle exec annotate --delete
Confirm that the comment has been deleted from the model, and execute it by migrate or manually.
.bash
$ bundle exec rails db:migrate
or
$ bundle exec annoatate --models
When I deleted it and migrated it, it was exported to all models.
After all, I didn't understand why annotate wasn't executed during migration, but for the time being, a comment was written out. If anyone knows the cause, I would appreciate it if you could comment.
Recommended Posts