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

How to safely upgrade Rails

How to safely upgrade Rails

Rails Upgrade Casual Talks at Crowd Works
https://cw-meetup.doorkeeper.jp/events/40728

Takashi Kokubun

March 28, 2016
Tweet

More Decks by Takashi Kokubun

Other Decks in Programming

Transcript

  1. ඇޓ׵ͷҰ࣌త཈੍ • Rails 4.2ͷAuthenticity Tokenͷมߋ͸ϩʔϧόοΫͰ͖ ͳ͍ͷͰɺRails 4.1ͷڍಈʹϞϯΩʔύονͰݻఆ • Masked Authenticity

    Token ͰຖճϥϯμϜͳtokenΛ ฦ͢Α͏ʹͳΔͷͰɺޙํޓ׵ੑ͕ͳ͍ • Rails 4.2σϓϩΠޙམ͍͔ͪͭͯΒ͜ͷύονΛ֎ͨ͠
  2. ඇޓ׵ͷҰ࣌త཈੍ ActiveSupport.on_load(:action_controller) do module ActionController module RequestForgeryProtectionExtension def form_authenticity_token session[:_csrf_token]

    ||= SecureRandom.base64(32) end end Base.prepend RequestForgeryProtectionExtension end end • Masked Authenticity TokenͷมߋΛ཈੍͢Δύον
  3. ෳ਺ϒϥϯνӡ༻ • ಉ͡ϦϙδτϦʹ cookpad.com ΛؚΉ8ͭͷΞϓϦ͕ಉډ ͍ͯ͠Δ͕ɺҰ౓ʹશ෦ϦϦʔε͠ͳ͍ • 8ͭͷΞϓϦ: ؅ཧը໘, όον,

    API, ϫʔΧʔ, ... • ໿1ि͔͚ؒͯஈ֊తʹσϓϩΠ͢Δ • શͯRails 4.2ʹҠߦ͢Δ·Ͱ͸Rails 4.1༻ͷrails41ϒϥϯν Λ࡞ΓmasterͷมߋΛόοΫϙʔτ͠ଓ͚Δ
  4. 2. ຊ൪؀ڥͰͷखಈ֬ೝ • ϞόΠϧΞϓϦ༻APIͷ৔߹ *OUFSOFU "QBDIF SBJMT SBJMT .PCJMF "QQ

    NJUNQSPYZ ϦΫΤετϔομʹ X-Foo=1 Λ͚ͭΔ X-Foo=1 ී௨ͷϦΫΤετ
  5. 3. Kage • https://github.com/cookpad/kage • ͋ΔαʔόʔʹདྷͨϦΫΤετΛRails 4.2ΛσϓϩΠͨ͠΋ͷʹ΋ྲྀ ͠ɺDBͳͲ΁ͷॻ͖ࠐΈ͸཈ࢭ͢Δ • MySQLͳΒBLACKHOLEɺmemcached

    ͳͲ͸ִ཭͢Δ • Τϥʔͷ༗ແ΍ύϑΥʔϚϯεΛ֬ೝ͢Δ • tail -f production.log • nginxͷϨεϙϯελΠϜ΍unicornͷϦιʔε࢖༻ྔ
  6. undefined method `unpack' for nil:NilClass • Rails 4.2.4ͱRuby 2.0.0ͷ૊Έ߹ΘͤͰͷΈൃੜ͢ΔΤϥʔ •

    Ruby 2.0.0ͩͱ ERB::Util.url_encode ಺ͷgsubͷϒϩο ΫͰ $& Λࢀর͢Δ͕ɺAS::SafeBuffer ͩͱಈ͔ͳ͍ • ຊՈʹ @k0kubun ͕ϓϧϦΛ౤͛ɺ4.2.5ʹऔΓࠐ·Εͨ • https://github.com/rails/rails/pull/21402