Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Read the release note of Rails 5.2

Read the release note of Rails 5.2

Kento Nagata

March 28, 2018
Tweet

More Decks by Kento Nagata

Other Decks in Programming

Transcript

  1. 2017.7.19 | ©2017 Wantedly, Inc.
    Read the release note of Rails 5.2
    Rails 5.2ͷϦϦʔεϊʔτΛಡΜͰݟΔ
    2018/03/28
    @ngtk

    View Slide

  2. 2017.7.19 | ©2017 Wantedly, Inc.
    2
    ઌिRails 5.2 RC2Ͱ·ͨ͠ΑͶ
    ิ଍͢Δݴ༿
    Read the release note of Rails 5.2

    View Slide

  3. 2017.7.19 | ©2017 Wantedly, Inc.
    3
    ಉ࣌ʹRelease Note΋ͰͨΑ͏ͳͷͰ

    ΈͯΈΑ͏ͱࢥ͍·ͨ͠
    Read the release note of Rails 5.2

    View Slide

  4. 2017.7.19 | ©2017 Wantedly, Inc.
    4
    - Major Features
    - Active Storage
    - Redis Cache Store
    - HTTP/2 Early Hints
    - Credentials
    - Content Security Policy


    - Changes on each
    modules
    - Action Pack
    - Action View
    - Action Mailer
    - Active Record
    - Active Model
    - Active Support
    - Active Job
    Release note contents

    View Slide

  5. 2017.7.19 | ©2017 Wantedly, Inc.
    5
    - Paperclip΍CarrierwaveͳͲͷ୅ସ͑
    - Amazon S3, Google Cloud Storage, Microsoft Azure
    Blob StorageΛόοΫΤϯυͱͯ͠ରԠ
    - μΠϨΫτΞοϓϩʔυ΋ରԠ
    - ײ૝: ࠓ͔Βஔ͖׵͑ΔఔͷϝϦοτ͸ͳͦ͞͏ͱ͍͏
    ҹ৅
    Active Storage

    View Slide

  6. 2017.7.19 | ©2017 Wantedly, Inc.
    6
    - ࠓ·Ͱ͸Ωϟογϡػߏͱͯ͠ɺϝϞϦ΍ϩʔΧϧετ
    ϨʔδɺMemcachedΛඪ४Ͱఏڙ
    - redis-railsͱ͍͏gem͕͕͋ͬͨɺඪ४ͰରԠͨ͠
    - hiredis(cͷ࣮૷)ʹ΋ରԠ
    - ײ૝: ඞཁͳ΋ͷ͕ͪΌΜͱऔΓࠐ·Εͨײ͋ͬͯྑ͍
    Redis cache store

    View Slide

  7. 2017.7.19 | ©2017 Wantedly, Inc.
    7
    - H2 Push͸ɺ༧ΊඞཁͳαϒϦιʔεΛฦ͓ͯͨ͘͠Ί
    ͷ࢓૊Έ
    - Reverse Proxy͕͋ͬͯOrigin͕H2Λ࿩ͤͳ͍৔߹ɺ
    H2 Push͸࢖͑ͳ͍
    - Early Hints͸ɺOrigin(H1.1)͕Reverse Proxy(H2)ʹα
    ϒϦιʔεΛ఻͑ΔͨΊͷ࢓༷
    HTTP/2 Early Hints

    View Slide

  8. 2017.7.19 | ©2017 Wantedly, Inc.
    8
    - RailsͰ͸ྫ͑͹`javascript_include_tag`΍
    `stylesheet_link_tag`ʹؚ·ΕͨϦιʔεΛ͕Μ͕Μ
    103 Early HintsͰฦ͍ͯ͘͠
    - ࠓͷͱ͜ΖpumaͷΈରԠ
    - ײ૝: pumaΛ࢖͍ͬͯΕ͹ҙ֎ͱγϡοͱԸܙΛड͚Ε
    ͦ͏ʁ
    HTTP/2 Early Hints

    View Slide

  9. 2017.7.19 | ©2017 Wantedly, Inc.
    9
    - credentials.yml.encͰ҉߸Խ͞ΕͨΩʔΛ؅ཧ͢Δ
    - 5.1Ͱಋೖ͞ΕͨEncrypted secrets͸ɺͳ͔ͬͨ͜ͱʹ
    ͳΓͦ͏
    - 伴͸RAILS_MASTER_KEYͰ؅ཧ
    Credentials

    View Slide

  10. 2017.7.19 | ©2017 Wantedly, Inc.
    10
    - ENVͰ੾Γସ͑Δͱ͔͸ߟ͑ΒΕ͍ͯͳ͍
    - ͭ·Γɺdevelopmentͱstagingͱ͔ͷ͜ͱ͸ߟྀ͞Ε
    ͍ͯͳ͍Ά͍
    - ͨͩ͠ɺࣗ෼ͰͦΕΒͷػߏΛ࡞Ε͹͍͚Δ͔΋ʁ
    - https://github.com/rails/rails/pull/
    30067#issuecomment-372760099
    Credentials

    View Slide

  11. 2017.7.19 | ©2017 Wantedly, Inc.
    11
    - ײ૝
    - ͳΜͰ͜͏ͳͬͨײ͕͍͢͝
    - ͋·Γඪ४ͷ࢓૊ΈʹཔΒͳ͍΄͏͕ྑͦ͞͏
    - ͜ͷล͸ଞͷϓϩδΣΫτͰͲ͏΍͍ͬͯΔͷ͔͕ؾ
    ʹͳΔ
    Credentials

    View Slide

  12. 2017.7.19 | ©2017 Wantedly, Inc.
    12
    - XSS΍ύέοτ౪ௌͳͲͷ߈ܸΛ๷͙ͨΊͷηΩϡϦ
    ςΟϨΠϠʔ
    - ίϯςϯπ͕औಘՄೳͳυϝΠϯΛઃఆ͢Δ͜ͱͰҙਤ
    ͠ͳ͍ίϯςϯπͷऔಘ΍࣮ߦΛ๷͙
    - secureheadersͱ͍͏Gem͕͕͋ͬͨɺඪ४ͰରԠ
    Content Security Policy (CSP)

    View Slide

  13. 2017.7.19 | ©2017 Wantedly, Inc.
    13
    - InitializerͰઃఆΛॻ͖·͢
    - ίϯτϩʔϥʔ͝ͱʹ΋ઃఆΛఆٛ͢Δ͜ͱ͕Ͱ͖·͢
    Content Security Policy (CSP)

    View Slide

  14. 2017.7.19 | ©2017 Wantedly, Inc.
    14
    - ײ૝
    - ͪΌΜͱ׆༻͍ͨ͠
    - ಋೖ͸ɺϩΪϯάΛͯ͠໰୊ΛݟΔ͚ΔϑΣʔζ͕͋
    Δ͸ͣͳͷͰɺͦͷ΁Μͷϊ΢ϋ΢΍ӡ༻ʹ͍ͭͯڞ
    ༗͍ͨ͠
    Content Security Policy (CSP)

    View Slide

  15. 2017.7.19 | ©2017 Wantedly, Inc.
    15
    - Bootsnap͸։ൃ؀ڥͰͷRailsىಈ࣌ؒΛૣ͘͢ΔGem
    - σϑΥϧτͰGemfileʹ௥Ճ͞ΕΔΑ͏ʹͳͬͨ
    Railties / Bootsnap

    View Slide

  16. 2017.7.19 | ©2017 Wantedly, Inc.
    16
    - Bootsnap͸ҎԼͷํ๏Ͱૣ͍ͯ͘͠Δ
    - require΍loadͷ݁ՌΛΩϟογϡ
    - RubyVM::InstructionSequeΛ࢖ͬͯrubyͷίʔυΛόΠφϦ
    σʔλԽͯ͠Ωϟογϡ
    - YAMLϑΝΠϧΛMessagePack(·ͨ͸Marshal)ͷܗࣜͰΩϟο
    γϡ
    Railties / Bootsnap

    View Slide

  17. 2017.7.19 | ©2017 Wantedly, Inc.
    17
    - ײ૝
    - WantedlyͰ΋ࡢ೥ಋೖͯ͠70%ىಈ͕ૣ͘
    ͳͬͨͷͰ͓͢͢Ί
    Railties / Bootsnap

    View Slide

  18. 2017.7.19 | ©2017 Wantedly, Inc.
    18
    - database.ymlͰYamlͷܧঝΛ࢖Θͣʹ஋Λڞ༗
    Ͱ͖ΔsharedηΫγϣϯΛ௥Ճ #28896
    - .ruby-version΍GemfileͰͷόʔδϣϯࢦఆͳ
    Ͳ͕σϑΥϧτͰߦΘΕΔΑ͏ʹͳͬͨɻ
    #30016
    Railties / Others

    View Slide

  19. 2017.7.19 | ©2017 Wantedly, Inc.
    19
    - database.ymlͰYamlͷܧঝΛ࢖Θͣʹ஋Λڞ༗
    Ͱ͖ΔsharedηΫγϣϯΛ௥Ճ #28896
    - .ruby-version΍GemfileͰͷόʔδϣϯࢦఆͳ
    Ͳ͕σϑΥϧτͰߦΘΕΔΑ͏ʹͳͬͨɻ
    #30016
    Railties / Others

    View Slide

  20. 2017.7.19 | ©2017 Wantedly, Inc.
    20
    - ΩϟογϡΩʔʹόʔδϣϯΛؚΊΔͷͰ͸ͳ
    ͘ɺΦϒδΣΫτΛ໊ࣔ͢લ͚ͩͱͯ͠ɺෆ༻
    ҙʹແବͳΩϟογϡΛੜ੒͢Δ͜ͱΛ๷͙Α
    ͏ʹͳͬͨ
    Action Pack / Recyclable cache keys

    View Slide

  21. 2017.7.19 | ©2017 Wantedly, Inc.
    21
    - ͨͱ͑͹ɺ`projects/1-20170202145500`ΛΩʔʹ͢ΔͷͰ͸ͳ
    ͘ɺΩʔΛΦϒδΣΫτ໊ͷ`projects/1`ͱͯ͠όʔδϣϯ
    `20170202145500`Λσʔλதʹอ࣋͢Δ
    - HTTPͷΩϟογϡͰͷɺURLͱETAGͱಉ͡Α͏ͳ΍Γํ
    Action Pack / Recyclable cache keys

    View Slide

  22. 2017.7.19 | ©2017 Wantedly, Inc.
    22
    - ׂѪ
    Action View

    View Slide

  23. 2017.7.19 | ©2017 Wantedly, Inc.
    23
    - ActiveJobͷ೚ҙΫϥε͕ࢦఆͰ͖ΔΑ͏ʹͳͬͨ #29457
    - ActionMailer͸͢΂ͯActionMailer::DeliveryJobΛར༻͍ͯ͠Δ
    - ΤϥʔϋϯυϦϯάͳͲ೚ҙͷରԠ͍ͨ͠έʔεͰ׆༻Ͱ͖ͦ͏
    Action Mailer

    View Slide

  24. 2017.7.19 | ©2017 Wantedly, Inc.
    24
    - [MySQL] descending indexΛαϙʔτ
    - Fixtureͷ౤ೖ࣌ʹͰBluk insert͢ΔΑ͏ʹͳͬͨ
    - ΫΤϦ͕ൃߦ͞ΕͨίʔυΛϩάͰग़ྗͰ͖ΔΑ͏ʹͳͬͨ
    Active Record
    3VCZHFN-PBE NT
    4&-&$5SVCZHFNT'30.SVCZHFNT8)&
    [email protected]

    View Slide

  25. 2017.7.19 | ©2017 Wantedly, Inc.
    25
    * ྫ֎`StatementTimeout`ͱ`LockWaitTimeout`ͱ`QueryCanceled`
    ͷ௥Ճ
    * `StatementTimeout`: λΠϜΞ΢τɺMySQLͱPostgresʹରԠ
    * `LockWaitTimeout`: ϩοΫͷλΠϜΞ΢τ
    * `QueryCanceled`: MySQLͷΈରԠɻPostgres͸
    `StatementTimeout`ʹ·ͱΊΒΕΔ
    Active Record

    View Slide

  26. 2017.7.19 | ©2017 Wantedly, Inc.
    26
    * destroyͨ͠ޙͷsaveͰ஋ΛมߋͰ͖ͳ͍Α͏ʹͳͬͨ
    * [Postgres] ֎෦ςʔϒϧͷαϙʔτ
    Active Record

    View Slide

  27. 2017.7.19 | ©2017 Wantedly, Inc.
    27
    • ׂѪ
    Active Model

    View Slide

  28. 2017.7.19 | ©2017 Wantedly, Inc.
    28
    • ׂѪ
    Active Support

    View Slide

  29. 2017.7.19 | ©2017 Wantedly, Inc.
    29
    • ׂѪ
    Active Job

    View Slide

  30. 2017.7.19 | ©2017 Wantedly, Inc.
    30
    • Redis cache store΍Early hintsͳͲ͸͙͢ʹ׆༻Ͱ͖ͦ͏
    • CSP͸ಋೖ͕࣌େมͦ͏͕ͩɺʮඪ४ͰରԠͰ͖Δରࡦʯ͕૿͑ͨ
    ͷ͸ͱͯ΋ྑ͍
    • Ωϟογϡͷόʔδϣχϯά΋׆༻Ͱ͖ͦ͏
    • BootsnapͰͷߴ଎Խ΍ActiveRecordͰͷ৽ػೳ͸೔ৗͰ׆༻Ͱ͖
    ͦ͏ͳ΋ͷ͕ଟ͍
    ·ͱΊ

    View Slide