[Ruby][Rails]script/destroyコマンド

[][]script/destroyコマンドは助かる。Add Star

script/generateでモデル名やコントローラ名をtypoした時、作られたファイルを一々手動で消すのは面倒。script/destroy使えばオッケー。

モデルを作って、消してみる。

> ruby script\generate model Hoges
      exists  app/models/
      exists  test/unit/
      exists  test/fixtures/
      create  app/models/hoges.rb
      create  test/unit/hoges_test.rb
      create  test/fixtures/hoges.yml
      exists  db/migrate
      create  db/migrate/002_create_hoges.rb

>ruby script\destroy model Hoges
    notempty  db/migrate
    notempty  db
          rm  db/migrate/002_create_hoges.rb
          rm  test/fixtures/hoges.yml
          rm  test/unit/hoges_test.rb
          rm  app/models/hoges.rb
    notempty  test/fixtures
    notempty  test
    notempty  test/unit
    notempty  test
    notempty  app/models
    notempty  app

コントローラを作って、消してみる。

>ruby script\generate controller Hellos
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/hellos
      exists  test/functional/
      create  app/controllers/hellos_controller.rb
      create  test/functional/hellos_controller_test.rb
      create  app/helpers/hellos_helper.rb

>ruby script\destroy controller Hellos
          rm  app/helpers/hellos_helper.rb
          rm  test/functional/hellos_controller_test.rb
          rm  app/controllers/hellos_controller.rb
       rmdir  test/functional
    notempty  test
       rmdir  app/views/hellos
    notempty  app/views
    notempty  app
    notempty  app/helpers
    notempty  app
    notempty  app/controllers
    notempty  app
執行migration文件
>rake db:migrate RAILS_ENV=production

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章