ãã®ã¨ã³ããªã¯ SmartHR Advent Calendar 2023ã®21æ¥ç®ã®è¨äºã§ãã
Railsã®ãã¼ã¸ã§ã³ãä¸ããä½æ¥ã¯ãåã«æ°ãããã¼ã¸ã§ã³ã®gemãã¤ã³ã¹ãã¼ã«ããã ãã§ã¯çµããã¾ãããRailsã®æ°ãããã¼ã¸ã§ã³ã«æ²¿ã£ãè¨å®é ç®ã確èªããé©å®é©ç¨ãã¦ããå¿ è¦ãããã¾ãããã¡ããå¿ ããããã¹ã¦ã®è¨å®ãææ°ã«ããªããã°ãªããªãããã§ã¯ããã¾ããããRailsã®æ°ããè¨å®ã¨ããã®ã¯åºæ¬çã«ãããããã¨ã«ã¡ãªãããããããä½ããã¦ããããã§ãç¹å¥ãªçç±ããªããã°ææ°ã®ç¶æ ã«ãã¦ãããããã®ã§ãã
ã¿ãªããã®Railsã¢ããªã±ã¼ã·ã§ã³ã®config/application.rb ã«ã¯æ¬¡ã®ãããªè¨å®ãããã¯ãã§ãã
config.load_defaults 6.1
ãã®ã³ã¼ããµã³ãã«ã¯å¼æ°ã6.1ãªã®ã§ãRails6.1ããã©ã«ãã®è¨å®ãé©ç¨ãã¦ãããã¨ã示ãã¦ãã¾ããããã7.0ã«ããã«ã¯ãã¾ãRailsèªä½ã7.0ã«ã¢ããã°ã¬ã¼ãããå¾ã«ä¸ã¤ãã¤å¿
è¦ãªè¨å®ã足ãã¦ããããã¹ã¦ã®è¨å®ã追å ããå¾config.load_defaults 7.0
ã«ããã®ãä¸çªæå
ãããæ¹ã ã¨æãã¾ã*1ã
Railsã®ãã¼ã¸ã§ã³ã¢ããã¨è¨å®å¤æ´ã¯å¥ã ã«ãã£ãã»ããè¯ã
ãã®ã¨ããrails gemã®ãã¼ã¸ã§ã³ã¨ä¸ç·ã«config.load_defaults
ã®å¼æ°ãå¤æ´ããã®ã¯æ¨å¥¨ãã¾ãããè¨å®ã®ä¸ã«ã¯ãããã¤ã®ãã¼ã«ããã¯ãå°é£ã«ãããã®ãããããã§ãã
ä¾ãã°Rails7.0ã§ã¯ãã£ãã·ã¥ã®å½¢å¼ãå¤æ´ããPRããã¼ã¸ããã¦ãã¾ãããã®ã³ãããã«ã¯äºææ§ã«ã¤ãã¦ã®èæ ®ããããRails7.0ã§ä½ãããæ°ããå½¢å¼ã®ãã£ãã·ã¥ã¨Rails6.1以åã«ä½ãããå¤ãå½¢å¼ã®ãã£ãã·ã¥ä¸¡æ¹ãèªããããã«ãªã£ã¦ãã¾ãããããRails6.1ã«ã¯ãã®ã³ãããã¯å«ã¾ãã¦ããªããããRails7.0å½¢å¼ã§ä½ããããã£ãã·ã¥ãRails6.1ã®ã¢ããªã±ã¼ã·ã§ã³ãèªããã¨ã¯ã§ãã¾ããã
ãã®ãã¨ãããRails7.0ã®ã¢ããã°ã¬ã¼ãã¨ãã£ãã·ã¥ã®å½¢å¼å¤æ´ãåæã«è¡ã£ãå ´åããããããã¤å¾ãã°ãããã¦ããä¸å ·åãè¦ã¤ããRails6.1ã«ãã¼ã«ããã¯ããã¨Rails7.0ã®éã«ä½ããããã£ãã·ã¥ã失ããããã¨ã«ãªã£ã¦ãã¾ãã¾ãããã£ãã·ã¥ã®å½¢å¼ã¯å¤ããã«Rails7.0ã®ã¢ããªã±ã¼ã·ã§ã³ããããã¤ããåé¡ãªããã¨ã確èªãã¦ããè¨å®ãå¤æ´ãããã¨ã§å®å ¨ã«ã¢ããã°ã¬ã¼ããé²ãããã¨ãã§ãã¾ãã
é©ç¨ãã¹ãè¨å®ä¸è¦§ã調ã¹ãæ¹æ³
load_defaultsã®åãã¼ã¸ã§ã³ã®å·®åã¯ãã³ã¼ããè¦ãã®ãæã£åãæ©ãã§ããrails app:update
ã§config/initializers/new_framework_defaults_7_0.rb
ã®ãããªãã¡ã¤ã«ãçæãããã¨ããæ¹æ³ãããã¾ããå人çã«ã¯ã³ã¼ããç´æ¥è¦ãã»ãã好ãã§ããRailsã®ã¢ããã°ã¬ã¼ãããããã¼ã¸ã§ã³ãcheckoutããRails::Application::Configuration#load_defaultsãè¦ã¾ãã
ä¾ãã°6.1ãã7.0ã«ã¢ããã°ã¬ã¼ããããã¨ãã¯æ¬¡ã®ã³ã¼ãã対象ã«ãªãã¾ãã
ãã®ã¨ããmainãã©ã³ãã®ææ°ãè¦ãã®ã¯æ¨å¥¨ãã¾ãããä¾ãã°config.load_defauts 6.1
ã«å«ã¾ãã active_record.legacy_connection_handling=falseã¨ããè¨å®ã¯Rails7.1ã§ã¯ããã©ã«ãã¨ãªãè¨å®ããã¯åé¤ãããã®ã§ãmainãã©ã³ãã®ã³ã¼ããåç
§ããã¨ãã®ãããªè¨å®ãè¦éãã¦ãã¾ãã¾ãã
ãã¨ã¯ã²ããããã£ã¦ããã®ã¿
ããããã³ã¼ãã®åè¨å®é¨åã®ã³ããããgit blameã§èª¿ã¹ã¾ããã³ãããã³ã¡ã³ããç´ã¥ãã¦ããPRã³ã¡ã³ãã¨ã³ã¼ãã®å·®åãèªã¿å 容ãç解ããä¸ã§ãã¢ããªã±ã¼ã·ã§ã³ã®ä¿®æ£ãå¿ è¦ããå¤æãã¦ããã¾ããä¿®æ£ãä¸è¦ã§ããã°config/application.rbãªã©ã«è©²å½ã®è¨å®ãè¨è¼ãã¦ã³ãããããã ãã§ãã
ä¸é¨ã®è¨å®ã¯ Upgrading Ruby on Rails â Ruby on Rails Guides ã«ã説æãè¨è¼ããã¦ããã®ã§ãã¡ããèªãã¨ç解ãæãã¾ãã
å
ç¨ã®ã³ã¼ããçºãã¦ã¿ãã¨ãconfig.load_defaults
ã®å¼æ°ã6.1ãã7.0ã«ããããã«ã¯æ大ã§21åã®è¨å®å¤æ´ãå¿
è¦ã«ãªãã¾ããããã¸ã§ã¯ãã«ãã£ã¦ã¯å©ç¨ãã¦ããªãã³ã³ãã¼ãã³ããããããå°ãæ°ãæ¸ãå¯è½æ§ã¯ããã¾ãããããã§ãå¤ããã¨ã«å¤ããã¯ããã¾ãããéä¸è¨å®ã調ã¹ã¦ããã®ã¯å¤§å¤ã§ãããæ®æ®µæèãããã¨ã®å°ãªãRailsã®å
é¨ä»æ§ã«ã¤ãã¦è©³ãããªãããæ©ä¼ã ã¨ãè¨ãã¾ããé å¼µã£ã¦ãã£ã¦ããã¾ããã*2ã