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

My patches for Rails 5

My patches for Rails 5

東急Ruby会議10 LT #tqrk10

Takashi Kokubun

May 29, 2016
Tweet

More Decks by Takashi Kokubun

Other Decks in Programming

Transcript

  1. ࠓ೔࿩͢͜ͱ • ๻͕ Rails 5.0 ʹ͍ΕͨҎԼͷύονʹؔͯ͠ࢥ͏ ͜ͱΛ࿩͠·͢ • #22722 Use

    CGI.escapeHTML for html escape • #18109 Allow joins to be unscoped • #22125 Alias left_joins to left_outer_joins
  2. • ݩ͸୯ͳΔ gsub(/[&"'><]/, { '&' => '&amp;', .. }) •

    ͜ΕΛ͔ͳΓ۪௚ʹCʹॻ͖௚͚ͨͩ͠ • UTF-8ؚΉASCIIޓ׵ͷΤϯίʔσΟϯάͰ࠷େ 7ഒߴ଎Խ • ext/cgi/escape ര஀ CGI.escapeHTMLͷߴ଎Խύον
  3. Ͳͷ͘Β͍มΘ͔ͬͨ • લఏ஌ࣝ: String࿈݁ͷݱࡏͷੑೳൺֱ TMJNͷDPNQJMFECFODIͷ)5.-Τεέʔϓ༗ޮ൛ JT    

         IBNMJU W TMJN W GBNM W FSVCJT W IBNM WCFUB https://travis-ci.org/k0kubun/hamlit/jobs/131694989
  4. #18109 Allow joins to be unscoped • (join͢Δ)includes, eager_load, joins

    Ͱ unscopedΛ࢖ͬͯ default_scope ͕֎ͤΔΑ ͏ʹͳΔ • 2೥͝͠ͷϚʔδ
  5. #22125 Alias left_joins to left_outer_joins • left_outer_joins ͷΤΠϦΞε left_joins Λ௥Ճ

    ͢Δ͚ͩ • ౰ͨΓલ͚ͩͲҒ͍ͷ͸๻ͷϓϧϦͰ͸ͳ͘ left_outer_joins Λ௥Ճ͢ΔํͷϓϧϦ • ·͋Ͱ΋left_outer_joinsͱ͔௕͗ͯ͢࢖Θͳ ͍ΑͶ
  6. ͦ΋ͦ΋ͳΜͰ left_outer_joins ͕ͦΜͳʹཉ͔͔ͬͨ͠ • ߜΓࠐΈͨΊͷLEFT OUTER JOINΛੜSQLΛ ࢖Θͣʹॻͨ͘ΊʹincludesΛ࢖͏ਓ͕͍Δ • eager

    loadͯ͠࢖͏Θ͚Ͱ΋ͳ͍Ϩίʔυͷ AR::BaseΠϯελϯε͕େྔʹ࡞ΒΕ஗͍ • ͦ͏͍͏༻్ͷϝιου͡Όͳ͍ͱϨϏϡʔ ͢ΔͱΠϯλʔωοτΛࠜڌʹ൓ൃ͞ΕΔ
  7. ༨ஊ: ͦͷincludesຊ౰ʹ଎͘ ͳΔ͔֬ೝͯ͠Δʁ • N+1௵ͯ͠ΫΤϦ͚ͩ଎ͯ͘͠΋τʔλϧͰ଎͘ͳΔͱ͸ ݶΒͳ͍ • ಛʹhas_many associationΛeager loadingͯ͠AR::Base

    ͕ಉ࣌ʹେྔʹ࡞ΒΕΔ৔߹ • ʮincludes଍ͯ͠N+1ͳ͘͠·ͨ͠ʂʯΈ͍ͨͳϓϧϦɺ લޙͷ଎౓ࠩΛషͬͯ΄͍͠ • rails sͷϩάݟΔ͚ͩͰ΋Θ͔Δ
  8. ·ͱΊ • Ruby 2.3 ͱ Rails 5.0 Λ࢖͏ͱerb͕଎͘ͳΔ • default_scope͸όάͬͯΔ͠ϝϯς͞Εͳ͍

    • includesͷ࢖͍ํΛݟ௚ͯ͠ཉ͍͠ • AR::Baseͷੜ੒ίετʹؾΛ͚ͭΑ͏