プログラミング

rails g でファイルの上書きがされないように注意しよう

Overwrite C:/pg/RAILS/dev___/app/controllers/dev_controller.rb? (enter "h" for help) [Ynaqdh] h
        Y - yes, overwrite
        n - no, do not overwrite
        a - all, overwrite this and all others
        q - quit, abort
        d - diff, show the differences between the old and the new
        h - help, show this help
Overwrite C:/pg/RAILS/dev___/app/controllers/dev_controller.rb? (enter "h" for help) [Ynaqdh] Y
       force  app/controllers/dev_controller.rb
       route  get 'dev/create'
get 'dev/update'
      invoke  erb
       exist    app/views/dev
      create    app/views/dev/create.html.erb
      create    app/views/dev/update.html.erb
      invoke  test_unit
    conflict    test/controllers/dev_controller_test.rb
  Overwrite C:/pg/RAILS/dev___/test/controllers/dev_controller_test.rb? (enter "h" for help) [Ynaqdh] Y
       force    test/controllers/dev_controller_test.rb
      invoke  helper
   identical    app/helpers/dev_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    coffee
   identical      app/assets/javascripts/dev.coffee
      invoke    scss
   identical      app/assets/stylesheets/dev.scss

それぞれの英単語の意味。

identical, 同一の
exist, 存在する
invoke, 呼び出す
conflict, 競合している
force, 強制的に
create, 作成

ここで注意したいのが、forceです。

forceと表示されているファイルは、上書きされたものになります。

上書きということは、それまでに書いていたコードが消えるっていうことなので、まじで気をつけないといけません。

といっても、forceの前には、overwirteしますか?という確認がされるので、ここでちゃんと英語を読んでれば避けられることでもあります。

基本的には、nでいいかと思いますが、気になるのであれば、dで差分を見ることもできるようです。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です