Rails 4.2→5.2アップデート

Rails 4.2→5.2アップデート

Rails 4.2を5.2にアップデートした時の流れをまとめました。

Ecf4ad5c20312b8499a615263519290a?s=128

horikawa

May 29, 2019
Tweet

Transcript

  1. Rails 4.2→5.2ʹ
 Ξοϓσʔτͨ͠ ງ઒ʢ@CASIXx1ʣגࣜձࣾπΫϧό

  2. • ීஈ͸ʮcowcamoʯͱ͍͏ΞϓϦΛ։ൃͯ͠ ·͢ • αʔόαΠυ͸ɺRailsΛ࢖ͬͯ·͢

  3. ࣮͸ͦΜͳʮcowcamoʯ ਺ϲ݄લ·Ͱ...

  4. Rails 4.2!!!

  5. Ruby 2.3!!!

  6. ্͛ͳ͖Όʢ࢖໋ײʣ

  7. gemͷΞοϓσʔτ
 ͔ͨ͜͠͠ͱͳ͍Μ͕ͩ...

  8. ʙ४උฤʙ

  9. ·ͣɺRubyΛ2.5ʹ্͛Α͏
 ʢ౰࣌ɺ2018೥11݄ࠒʣ

  10. ্͛ͨ
 Τϥʔ͸ग़ͳ͔ͬͨ

  11. ্͛Δ࣌ʹɺ
 ͍ͭͰʹRailsΞοϓσʔτ
 Ͱ΋࢖͑Δ΋ͷΛ༻ҙͨ͠

  12. ಈ࡞֬ೝ߲໨ॻΛ࡞͓͍ͬͯͨ • ಈ࡞֬ೝͷγφϦΦΛ࡞Γ • ސ٬ͷಈ࡞Λ࠷௿ݶ୲อ͍ͨ͠ϥΠϯ • ۀ຿্ΫϦςΟΧϧͳՕॴ͸୲อ͍ͨ͠ͳ ͲΛఆٛ • ͦΕΛݩʹ߲໨ॻΛ࡞੒

  13. ͱ͸͍͑ɺ
 ͜Ε͚ͩͰ͸৺΋ͱͳ͍...

  14. ϦάϨογϣϯςετ΋
 ڧԽͤͶ͹

  15. ϢχοτςετͷΧόϨοδΛ 80% ͙Β͍·Ͱ্͛ͨ

  16. Issueࣄલ༻ҙ͠ͳ͖Ό

  17. ͝ஸೡʹΞοϓάϨʔυΨΠυ͕
 ༻ҙ͞ΕͯΔͧʂ

  18. ྔগͳw

  19. None
  20. ...ϦϦʔεϊʔτΛݟΑ͏

  21. Issue༻ҙ • 5.0, 5.1, 5.2 ͷϦϦʔεϊʔτͱʮcowcamoʯͷ ίʔυΛൺֱͯ͠ɺରԠ͢΂͖issueΛ੾ͬͨ • ࠓճɺେྔʹissue͕ग़ͦ͏ͳͷͰɺ֤όʔδϣϯ ͱ༏ઌ౓ͰϥϕϧΛ࡞͓͍ͬͯͨʢ͜Ε͸ྑ͔ͬ

    ͨͰ͢ʂʣ • Rails5.0:MUST, Rails5.0:SHOULDΈ͍ͨͳ...
  22. Αʔ͠ɺ্͛Δ͔ʔ

  23. Rails 5.0

  24. खॱ • Rails 5.0ʹ্͛Δ 1. ϦάϨογϣϯςετͰΤϥʔग़Δ 2. Issueʹ͢Δ 3. मਖ਼͢Δͷϧʔϓ

    • ࣄલ༻ҙͨ͠Issue΋ফԽ͍ͯ͘͠
  25. ͜͜Ͱ෼͔ͬͨ͜ͱ...

  26. ϦϦʔεϊʔτʹࡌͬͯͳ͍ มߋͰͨ͘͞ΜΤϥʔ͕ग़ͨ

  27. ΍ͬͱফԽͨ͠ʂ
 ͱࢥ͍͖΍

  28. ௚લͰ໰୊ൃੜ

  29. Rails 4.2Ͱ࡞੒ͨ͠
 δϣϒΛ࢖͑ͳ͍

  30. σγϦΞϥΠζͰ͖ͳ͍໰୊ • Rails 4.2ͷ࣌ʹδϣϒΛ
 ϚʔγϟϧγϦΞϥΠζ͍ͯͨ͠ • Rails 4.2ʹ͸͋ͬͯɺ5.0ʹ͸ͳ͍ΫϥεΛؚΊͯγϦ ΞϥΠζ͍ͯͨ͠ͷͰɺσγϦΞϥΠζ͢Δࡍʹɺ
 ఆ਺Τϥʔ͕ൃੜ

    • ActiveRecord::ConnectionAdapters::AbstractMysql Adapter::MysqlDateTimeͱ͔...
  31. ղܾࡦ • δϣϒ • Rails 4.2ʹ͋ͬͯɺRails 5.0ʹ͸ͳ͍Ϋϥε ͸ɺμϛʔͰఆٛͨ͠ • 4.2ͷδϣϒΛফԽͨ͠Βɺ࡟আ

  32. Rails 4.2͔Βෳ੡

  33. ͍ͭʹϦϦʔεʂʂ

  34. ੒ޭʂ ͔͠΋ϊʔΤϥʔͩͱ...!?

  35. ଓ͍ͯ5.1ʂ

  36. Rails 5.1

  37. 5.1Ͱগۤ͠࿑ͨ͠Օॴ

  38. uniq→distinctมߋ • ActiveRecordͱ
 ActiveRecord::ActiveRecord_Relationͷ
 uniqϝιου͕distinctϝιουʹมߋ͞Εͨ

  39. uniq→distinctมߋ • ActiveRecord::ActiveRecord_Relation ͸Array ͷuniqϝιουΛҕৡ͍ͯ͠ΔͷͰɺ
 uniq→distinctʹ௚͠๨Εͯ΋ɺ
 NoMethodError͕ग़ͳ͍... • ·ͨɺArrayͰ͸Ҿ͖ଓ͖ɺuniqΛ࢖͏ͷͰɺ
 શͯdistinctʹ௚ͤ͹͍͍Θ͚Ͱ͸ͳ͍

  40. Rails 5.2

  41. image_tagͷมߋ͕...

  42. image_tag໰୊ • CarrierWaveͷUploaderͬͯ͋Δ͡Όͳ͍Ͱ ͔͢

  43. image_tag໰୊ • ࠓ·Ͱ͸ɺ
 image_tag(@image_uploader_object)Έ͍ͨ ʹ
 ΠϝʔδΞοϓϩʔυΦϒδΣΫτΛೖΕͯ΋ ͳΜ΍͔Μ΍ͯ͘͠Ε͕ͨɺͯ͘͠Εͳ͘ͳͬ ͨ

  44. image_tag໰୊ • ۩ମతʹ͸ɺ • Can't resolve image into URL: undefined

    method `to_model' for #<MyUploader:xxxxxxxxxx>
 Did you mean? to_xml • ͳΔΤϥʔ͕ग़·͢
  45. image_tagղܾࡦ • ୈҰҾ਺ʹɺURLͷจࣈྻΛ௚઀౉ͤͱͷ͜ ͱͩͬͨͷͰ • image_tag(@image_uploader_object)
 ↓
 image_tag(@image_uploader_object.url) • ʹॻ͖׵͑ͨ

  46. ͪͳΈʹ • mount_uploader :url, MyUploaderΈ͍ͨʹॻ ͍͍ͯΔͱ... • image_tag(@profile_image.url.url) Έ͍ͨʹ ͳΓ·͢


    
 ŘşũūŘ
  47. ·ͱΊ

  48. ྑ͔ͬͨͱ͜Ζ • ϢχοτςετͷΧόϨοδΛ80%ॻ͍ͨ • ઈରʹΤϥʔग़ͨ͘͠ͳ͍Օॴ͸ɺ
 ಈ࡞֬ೝ߲໨ॻΛ࡞੒ͯ͠ɺखಈͰͷ֬ೝΛͨ͜͠ͱ • ݹ͍؀ڥ(4.2)→৽͍͠؀ڥ(5.0ͳͲ)ͷ֬ೝΛͨ͜͠ ͱ •

    ηογϣϯɾδϣϒͷෆ۩߹Λݟ͚ͭΒΕΔ
  49. ૝ఆ֎ͩͬͨՕॴ • ϦϦʔεϊʔτΛ֬ೝͨ͠Βɺे෼ͩͱࢥ͍ ࠐΜͰ͍͕ͨɺ
 ϦϦʔεϊʔτʹͳ͍มߋͳͲ΋Τϥʔ͕ग़ ͍ͯͨ(શମͷ30~40%͙Β͍) • ϦάϨογϣϯςετΛॻ͍ͯɺ্͛ͯɺΤ ϥʔΛ௵͍ͯ͘͠ํ͕ϝΠϯʹͳΓͦ͏

  50. None
  51. RailsΞοϓσʔτ͸
 ϊʔΤϥʔͰͨ͠ ☀