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

Railsの設計 〜コントローラの メタボを防げ〜 / rails-controller-de...

Railsの設計 〜コントローラの メタボを防げ〜 / rails-controller-design

2020-01-30 Gotanda.rb #41のLT資料です!
『Railsの設計 〜コントローラの メタボを防げ〜』

https://gotanda-rb.connpass.com/event/162164/

WalkerSumida

January 30, 2020
Tweet

More Decks by WalkerSumida

Other Decks in Technology

Transcript

  1. w େֶߦ͖ͳ͕Β*5ϕϯνϟʔاۀͰ໿೥ؒ༗ঈΠϯλʔϯ w 1)1 .Z42- $BLF1)1 Y 8PSEQSFTT $ "41

    /&5 w ౦ࣳ৘ใγεςϜגࣜձࣾͰ೥ؒϔϧεέΞࣄۀʹैࣄ w 7#/&5 $ 0SBDMF%BUBCBTF w ̍ਓͰىۀ͠Α͏ͱࢼΈΔ͕ࣦഊ w 3VCZPO3BJMT 'VFM1)1 .Z42- "84 "OTJCMF w גࣜձࣾϚπϦΧʹΤϯδχΞೋਓ໨ͷ૑ۀϝϯόʔͱͯ͠+PJO w /PUJBࣄۀ੹೚ऀ݉4FOTFTϓϩμΫτϚωʔδϟʔ w 3VCZPO3BJMT "OHVMBS+4 .Z42- "84 ܦྺ
  2. w ΞυϨεՄೳੑ "EESFTTBCJMJUZ  w ఏڙ͢Δ৘ใ͕63*Λ௨ͯ͠දݱͰ͖Δ͜ͱɻશͯͷ৘ใ͸63*Ͱදݱ͞ΕΔҰҙͳΞυϨεΛ࣋ͬ ͍ͯΔ͜ͱɻ w εςʔτϨεੑ 4UBUFMFTT

     w )551Λϕʔεʹͨ͠εςʔτϨεͳΫϥΠΞϯταʔόϓϩτίϧͰ͋Δ͜ͱɻηογϣϯ౳ͷ ঢ়ଶ؅ཧ͸ͤͣɺ΍ΓऔΓ͞ΕΔ৘ใ͸ͦΕࣗମͰ׬݁ͯ͠ղऍͰ͖Δ͜ͱɻ w ઀ଓੑ $POOFDUBCJMJUZ  w ৘ใͷ಺෦ʹɺผͷ৘ใ΍ ͦͷ৘ใͷผͷ ঢ়ଶ΁ͷϦϯΫΛؚΊΔ͜ͱ͕Ͱ͖Δ͜ͱɻ w ౷ҰΠϯλʔϑΣʔε 6OJGPSN*OUFSGBDF  w ৘ใͷૢ࡞ औಘɺ࡞੒ɺߋ৽ɺ࡟আ ͸શͯ)551ϝιου (&5ɺ1045ɺ165ɺ%&-&5& Λར༻͢ Δ͜ͱɻ ˞ࢀߟIUUQTRJJUBDPN/BHBPLB,FOJDIJJUFNTDFGDFEGCG 3&45ͬͯͳΜ͚ͩͬ
  3. w ӈͷ5SFMMPͷϖʔδΛදࣔ͢Δͷ ʹ͸ɺ#PBSE -JTU $BSE "DUJWJUZ ͳͲͷ৘ใ͕ඞཁͰ৭ʑͳϦιʔ ε͕͋Δ͕ɺྫ͑͹ͭͷ"1*Λୟ ͘ͱશͯͷϦιʔε͕Ͱ͖ɺӈͷ ϖʔδΛදࣔ͢Δ͜ͱ͕Ͱ͖Δɺ

    ͱ͍͏ͷ͸ʮ͋ΔϖʔδΛ։ͨ͘ Ίͷ"1*ʯͱ͍͏͜ͱͰݻ༗ͷ ϢʔεέʔεʹͳΔ w ͜ΕΛ΍Δͱ૝૾Ͱ͖ΔΑ͏ʹί ϯτϩʔϥ͕ϝλϘʹͳΔ ݻ༗ͷϢʔεέʔεͷۃ୺ͳྫ
  4. class ItemsController < ActionController::API # GET /items def index; end

    # GET /items/{id} def show; end # POST /items def create; end # PATCH /items/{id} def update; end # DELETE /items/{id} def destroy; end end ϝλϘʹͳΒͳ͍ͨΊͷίϯτϩʔϥͷॻ͖ํͱ͸
  5. class ItemsController < ActionController::API # GET /items def index; end

    # GET /items/{id} def show; end # POST /items def create; end # PATCH /items/{id} def update; end # DELETE /items/{id} def destroy; end # POST /items_bulk def bulk_create; end # ͜Ε͸΍Βͳ͍΄͏͕͍͍ # PATCH /items_bulk def bulk_update; end # ͜Ε͸΍Βͳ͍΄͏͕͍͍ end ϝλϘʹͳΔίϯτϩʔϥͷॻ͖ํ
  6. class ItemsController < ActionController::API # GET /items def index; end

    # GET /items/{id} def show; end # POST /items def create; end # PATCH /items/{id} def update; end # DELETE /items/{id} def destroy; end end class Bulk::ItemsController < ActionController::API # POST /bulk/items def create; end # PATCH /bulk/items def update; end end ϝλϘʹͳΓʹ͘ίϯτϩʔϥͷॻ͖ํ
  7. w ॳΊ͸׳Εͳ͍͔΋͠Εͳ͍͕ɺͲΜͳϦιʔε JUFN VTFS  QBZNFOU Ͱ͋ͬͯ΋ɺJOEFY TIPX DSFBUF VQEBUF

    EFTUSPZϝ ιουͰ࡞੒͢Δ w %))ࢯ͕ݴ͍ͬͯΔ w IUUQTQPTUEDDIPXEIIPSHBOJ[FTIJTSBJMTDPOUSPMMFST ίϯτϩʔϥͷॻ͖ํʹ౷ҰੑΛ
  8. w ιʔτͷঢॱ߱ॱ w JEঢॱJUFNT TPSU JE w JE߱ॱJUFNT TPSUJE w

    ιʔτͷෳ਺ࢦఆ w JE߱ॱ OBNFঢॱJUFNT TPSUJE OBNF w ιʔτͷঢॱ߱ॱσϑΥϧτ஋ w JUFNT TPSUJEͱͨ͠৔߹ঢॱͱͳΔ ιʔτฤ
  9. w ίϯτϩʔϥΛϝλϘʹ͠ͳ͍ͨΊʹݻ༗ͷϢʔεέʔεΛຬ ͨͦ͏ͱ͢Δ"1*ͷઃܭࢥ૝͸΍Ί·͠ΐ͏ w ͭͷίϯτϩʔϥʹϝιουΛੜ΍͠·͘Δͷ͸΍Ί·͠ΐ ͏ w جຊతʹ͸JOEFY TIPX DSFBUF

    VQEBUF EFTUSPZҎ֎͸ͳΔ ΂͘࢖Θͳ͍Α͏ʹ͠·͠ΐ͏ w "1*ͷઃܭͰ೰ΜͩΒɺ৭ʑͳαʔϏεͷ0QFO"1*ͷ࢖༻ͳͲ Λࢀߟʹͯ͠Έ·͠ΐ͏ ·ͱΊ