99
71

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

開発中に rails generate や db:migrate をやり直したい時

Last updated at Posted at 2015-07-28

やり直す方法を知っていることは、心の安定に繋がります。
ということで、やり直しの方法をまとめます。

rails generate controller をやり直す方法

$ rails generate controller FooBars hage
「あ、やっちゃった!」
$ rails destroy controller FooBars
「ふ~、助かった」

rails generate model をやり直す方法

$ rails generate model Foo hage
「また、やっちゃった!」
$ rails destroy model Foo
「ふ~、助かった」
(モデル名以外の引数は不要)

その他、rails generate integration_test なども同じ要領でやり直せます

migrateをやり直す方法

$ rake db:migrate
「うぎゃー」
$ rake db:rollback
「ふ~」
~中略~
「うーん、最初の状態に戻そう」
$ rake db:migrate VERSION=0

99
71
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
99
71

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?