LoginSignup
0
0

More than 1 year has passed since last update.

bin/rails app:update で routes.rb をキレイに上書きしてしまった話

Posted at

概要

  • Rails を 6.0.0 から 6.1.3 にバージョンアップしようとしていた
  • bin/rails app:update を実行し、出てくるプロンプトを脳死で全て Y で許可した
  • 結果、config/routes.rb をまっさらなものに上書きしてしまった

参考記事

"Warning, there can be breaking changes to your application if you accept all changes suggested. (i.e. getting a new clean routes.rb file.)
Be careful with your choices!"

この記事はこの 2 文に尽きます。

詳細

Rails をバージョンアップする際に config 周辺のファイルの更新をしようとbin/rails app:updateを実行しました。

実行して、もしファイルに conflict が発生した場合には

    conflict  config/routes.rb
Overwrite /sample/config/routes.rb? (enter "h" for help) [Ynaqdhm] 

と聞かれます。脳死で Y を押すと聞かれている通り Overwrite されてしまいますので、
差分を見て上書きしても問題ないか確認する必要があります。

記載の通り h で help を見ると

        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
        m - merge, run merge tool

と説明がでるので、d

--- /sample/config/routes.rb   2021-05-31 15:57:03.000000000 +0900
+++ /sample/config/routes.rb20210604-77510-10uw86v     2021-06-04 09:46:51.000000000 +0900
@@ -1,3 +1,3 @@
 Rails.application.routes.draw do
-  root 'application#hello'
+  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
 end
Retrying...
Overwrite /sample/config/routes.rb? (enter "h" for help) [Ynaqdhm] 

と差分が確認できます。
更新したくない場合は n でスキップすればよいのですね。

まとめ

何か聞かれたらちゃんと内容を聞きましょう。

0
0
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
0
0