特定のテーブルのデータをすべて消去する方法
前提
db/seedにデータを入れていた。
データを変更したいので一旦消去することにした。
方法
rsils c
Food.all.destroy_all
解説
rsils c
Food.all.destroy_all
複数のデータを削除するときにはdestroy_allを使う。
結果
参考にしたサイト
Author And Source
この問題について(特定のテーブルのデータをすべて消去する方法), 我々は、より多くの情報をここで見つけました https://qiita.com/TOM_3rd/items/06d3a5864acd950ad524著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .