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

プロを目指すRailsエンジニアのための公開コードレビュー / #railsdm

プロを目指すRailsエンジニアのための公開コードレビュー / #railsdm

Rails Developers Meetup #4の発表資料です。

全員分のコードレビュー動画はこちらにあります。

【前編】全部見ます!プロを目指すRailsエンジニアのための公開コードレビュー #railsdm
https://youtu.be/xZk4f4PPUhU

【後編】全部見ます!プロを目指すRailsエンジニアのための公開コードレビュー #railsdm
https://youtu.be/yDxg0sXHXOo

勉強会の告知ページはこちらです。

Rails Developers Meetup #4 リモート会場 - connpass
https://rails-developers-meetup.connpass.com/event/63374/

Junichi Ito

August 24, 2017
Tweet

More Decks by Junichi Ito

Other Decks in Programming

Transcript

  1. ϓϩΛ໨ࢦ͢3BJMTΤϯδχΞͷͨΊͷ
    ެ։ίʔυϨϏϡʔ
    גࣜձࣾιχοΫΨʔσϯ
    ҏ౻३Ұ
    3BJMT%FWFMPQFST.FFUVQ

    View full-size slide

  2. ABOUT ME
    ҏ౻३Ұ
    ➤ େࡕ෎๛தࢢग़਎
    ➤ ฌݿݝ੢࿬ࢢࡏॅ
    ➤ גࣜձࣾιχοΫΨʔσϯ
    ➤ 3BJMTϓϩάϥϚ
    ➤ ϦϞʔτϫʔΧʔ
    ➤ Ϊλʔ޷͖
    ➤ ࠓ೔.BUFVT"TBUP؍͖ͯͨʂ

    View full-size slide

  3. ͜Μͳͱ͜ΖʹॅΜͰ·͢

    View full-size slide

  4. Έͳ͞Μ͸ࠓͲ͜ʹʁ
    #railsdm ͰπΠʔτʂ

    View full-size slide

  5. ͪ͜Βͷ࢓ࣄ෦԰͔Β์ૹதͰ͢

    View full-size slide

  6. πΠʔτΛνΣοΫʂ
    IUUQTUXJUUFSDPNIBTIUBHSBJMTEN TSDIBTI

    View full-size slide

  7. ޷ධൃചதʂ
    &WFSZEBZ3BJMT

    34QFDʹΑΔ3BJMTςετೖ໳
    ➤ 3BJMTͰςετΛॻ͘ͳΒ͜Εʂ
    ➤ ߋ৽͕͋Ε͹ແྉΞοϓσʔτ
    ➤ 3BJMT൛΋຋༁͢Δ༧ఆ
    ➤ &16#ɺ.PCJɺ1%'ʹରԠ
    ➤ -FBOQVCͷ8FCαΠτͰൢചத

    View full-size slide

  8. ٕज़ॻ͕ग़·͢ʂ
    ʮϓϩΛ໨ࢦ͢ਓͷͨΊͷ3VCZೖ໳ʯ
    ➤ ҏ౻३Ұஶ
    ➤ ೥݄ൃച
    ➤ #มܕ൑ϖʔδ
    ➤ ग़൛ࣾɿٕज़ධ࿦ࣾ
    ˞্ه಺༰͸ݱ࣌఺ͷ༧ఆͰ͢ɻ
    ͲΜͳຊͳͷʁ
    ➤ 2JJUB౳Ͱఆධͷ͋Δஸೡͳղઆ
    ➤ 5%%ˍνϡʔτϦΞϧܗࣜͷྫ୊
    ➤ ։ൃͷݱ৔Ͱ໾ཱͭ஌͕ࣝຬࡌ
    ϓϩΛ໨ࢦ͢ਓͷͨΊͷ
    3VCZೖ໳
    ҏ౻३Ұஶ
    ٕज़ධ࿦ࣾ

    View full-size slide

  9. ࠓճͷ͓୊͸͜ͷຊͷྫ୊ΛϞσΟϑΝΠ
    ʮୈ̓ষΫϥεͷ࡞੒Λཧղ͢ΔʯΑΓൈਮ

    View full-size slide

  10. ຊ೔ͷΞδΣϯμ

    View full-size slide

  11. ຊ೔ͷΞδΣϯμ
    ➤ ެ։ίʔυϨϏϡʔɾͦͷ̍
    ➤ ެ։ίʔυϨϏϡʔɾͦͷ̎
    ➤ ग़୊ऀͷղ౴ྫ
    ➤ ؾʹͳͬͨϙΠϯτ͋Ε͜Ε
    ➤ ·ͱΊ
    ➤ ࣭ٙԠ౴ʢ͕࣌ؒ͋Ε͹ʣ
    ➤ ࣭໰΍͝ҙݟ͸SBJMTENΛ෇͚ͯπΠʔτ
    ➤ ΈΜͳͰʮྑ͍ίʔυʯʹ͍ͭͯҰॹʹߟ͑ͯΈ·͠ΐ͏ʂ

    View full-size slide

  12. ίʔυϨϏϡʔຊ໨

    View full-size slide

  13. ̍ຊ໨ͷίʔυϨϏϡʔ͸ͪ͜Βʂ
    IUUQTHJUIVCDPN+VOJDIJ*UPUSBJOUJDLFUSBJMTQVMM

    View full-size slide

  14. ίʔυϨϏϡʔຊ໨

    View full-size slide

  15. ̎ຊ໨ͷίʔυϨϏϡʔ͸ͪ͜Βʂ
    IUUQTHJUIVCDPN+VOJDIJ*UPUSBJOUJDLFUSBJMTQVMM

    View full-size slide

  16. ग़୊ऀͷղ౴ྫ

    View full-size slide

  17. ๻ͷղ౴ྫͰ͢
    IUUQTHJUIVCDPN+VOJDIJ*UPUSBJOUJDLFUSBJMTDPNQBSFNBTUFSBOTXFS

    View full-size slide

  18. ؾʹͳͬͨ఺͋Ε͜Ε

    View full-size slide

  19. ࢖༻ࡁΈͷ੾ූʁ

    View full-size slide

  20. ࢖༻ࡁΈͷ੾ූΛද͢ίʔυ
    1. OJMͰͳ͚Ε͹ਅ
    ➤ redirect_to ʙ if @ticket.exited_gate
    2. QSFTFOU Ͱʮʙ͕ଘࡏ͍ͯ͠Ε͹ʯΛ໌ࣔ
    ➤ redirect_to ʙ if @ticket.exited_gate.present?
    3. ΠϯελϯεϝιουΛ࡞ͬͯந৅Խ
    ➤ redirect_to ʙ if @ticket.used?
    ➤ ύλʔϯ͕̏ಡΈखʹҰ൪΍͍͞͠

    View full-size slide

  21. ʁͰऴΘΔϝιουͷ੹຿

    View full-size slide

  22. ʁͰऴΘΔϝιουͷ੹຿Λߟ͑Δ
    ➤ before_action :ticket_used?
    ➤ validate :can_exit?
    ➤ ྫɿIUUQTHJUIVCDPN+VOJDIJ*UPUSBJOUJDLFUSBJMTQVMM
    ➤ ಛఆͷ৚݅ͰϦμΠϨΫτ͢Δʢ͍͍ͷʁʣ
    ➤ ಛఆͷ৚݅ͰΤϥʔϝοηʔδΛ௥Ճ͢Δʢ͍͍ͷʁʣ
    ➤ ʁͰऴΘΔϝιου͸ਅِ஋Λฦ͚ͩ͢ʹ͢Δ
    ➤ ͦΕҎ֎ͷ෭࡞༻͸࣋ͨͤͳ͍
    ➤ ྫ֎ɿ"DUJWF3FDPSEͷWBMJE ϝιου

    View full-size slide

  23. redirect_to + returnʁ

    View full-size slide

  24. redirect_to + return ͷ return ͍ͬͯΔʁ
    ➤ ͦͷSFUVSOɺ͍Γ·͢ʁʢ͍Γ·ͤΜʂʣ
    def abort_used_ticket
    if @ticket.used?
    rediect_to root_path
    return
    end
    end

    View full-size slide

  25. redirect_to + return ͷ return ͍ͬͯΔʁ
    ➤ ͨͩ͠ɺ࣍ͷΑ͏ͳίʔυͳΒSFUVSO͸ඞཁ
    def abort_used_ticket
    if @ticket.used?
    rediect_to root_path
    # Avoid DoubleRenderError
    return
    end
    redirect_to foo_path
    end
    SFEJSFDU@UP΍SFOEFSΛෳ਺ճݺͿͱ%PVCMF3FOEFS&SSPS

    View full-size slide

  26. ·ͱΊ
    ➤ ϝιουͷ੹຿Λߟ͑Α͏
    ➤ ੹຿΍෭࡞༻͸Ͱ͖Δ͚ͩগͳ͘
    ➤ ͍͍ײ͡ʹந৅Խ͠Α͏
    ➤ ʮҙਤΘ͔ΔϩδοΫʯΑΓ΋ʮҙਤ͕෼͔Δ໊લʯΛ
    ➤ ෆཁͳίϯςΩετΛͳͦ͘͏
    ➤ ࡞ͬͨਓ͚͕ͩΘ͔ΔʮӅΕͨҙຯʯ͸ഉআ͢Δ
    ➤ 3BJMTͷػೳΛ࢖͍͜ͳͦ͏
    ➤ γϯϓϧͰෆ۩߹ͷͳ͍ίʔυΛ໨ࢦͦ͏
    ➤ ͔ͩΒɺ͓ޓ͍ʹίʔυϨϏϡʔ͓͋͠͏ʂʂ

    View full-size slide

  27. THANK YOU FOR ALL!
    ➤ ղ౴Λૹͬͯ͘ΕͨΈͳ͞Μɺ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ
    IUUQTHJUIVCDPN+VOJDIJ*UPUSBJOUJDLFUSBJMTQVMMT

    View full-size slide

  28. ͔ͤͬ͘ͳͷͰɺ

    View full-size slide

  29. શһʹίϝϯτ͠·͢ʂ

    View full-size slide

  30. શһͷղ౴ʹίϝϯτ͠·͢
    ➤ ͨͩ͠ςΩετͩͱେมͳͷͰɺޱ಄Ͱίϝϯτ͠·͢
    ➤ ίʔυΛݟͳ͕Β๻͕ίϝϯτΛೖΕΔಈըΛ࡞Γ·͢
    ➤ ಈը͕Ͱ͖ͨΒൃදࢿྉͷҰ෦ͱͯ͠ެ։ˍ௨஌͠·͢
    ➤ ର৅͸ݱ࣌఺ͰૹΒΕ͖͍ͯͯΔશϓϧϦΫΤετ
    ָ͓͠Έʹʂʂ

    View full-size slide

  31. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
    Twitter: !KODIJUP
    Blog: IUUQCMPHKOJUPDPN
    Qiita: IUUQRJJUBDPNKODIJUP
    Follow me!

    View full-size slide