LoginSignup
8
5

More than 3 years have passed since last update.

【RubyonRails入門】生成したコードを元に戻す方法

Last updated at Posted at 2019-09-10

忘備録です。

1.コントローラの自動生成と、それに対応する取り消し処理の例

 $ rails generate controller StaticPages home help
=> StaticPagesの home,helpアクションを作成

 $ rails destroy  controller StaticPages home help
=> StaticPagesの home,helpアクションを削除

2.モデルの自動生成と、それに対応する取り消し処理の例

$ rails generate model User name:string email:string
=> Userモデルに、name,emailカラムを追加

$ rails destroy model User
=> Userモデルを削除

3.マイグレーションの変更を元に戻す

$ rails db:migrate
=> migrationする

$ rails db:rollback
=> migrationしたものを、1つ前の状態に戻す

$ rails db:migrate VERSION=0
=> 最初の状態に戻す
8
5
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
8
5