Rails Developers Meetup

0c471249ee93ab17a011f3e8d2b1057a?s=47 AKAMATSU Yuki
November 16, 2017

Rails Developers Meetup

0c471249ee93ab17a011f3e8d2b1057a?s=128

AKAMATSU Yuki

November 16, 2017
Tweet

Transcript

  1. 6.

    ೝࣝҧ͍ͷൃੜͱ͸ w ྫ͑͹ w Ϗδωεଆͷࢥ࿭ʮͱΓ͋͑ͣ.71ͱͯ͠ϦϦʔεͯ͠ػೳͱͯ͠ඞཁ͔֬ ೝ͍ͨ͠ʯ w ։ൃଆͷࢥ࿭ʮͱ͘ʹԿ΋ݴΘΕͯͳ͍͠ɺ࡞ΓࠐΜͰ͠·͍͍ͬͯΜͩΖ ͏ʯ w

    Ϗδωεͱ։ൃͷར֐ͷෆҰகͱ͔΋͋Δ w Ϗδωε͸ച্΍ϦϦʔεεϐʔυΛؾʹ͢Δ͕ɺ։ൃଆ͸কདྷతʹࣗ෼ୡ ͕ۤ࿑͠ͳ͍͔Ͳ͏͔Λؾʹ͢Δ w ։ൃʮԾઆݕূ͕͏·͍ͬͨ͘Β࡞Γͳ͓࣌ؒ͢Λ࡞Δ͘ΕΔͱݴ͚ͬͨͲ ͍ͭ΋͘Εͳ͍΍Μ͚ʜʯ w ҆શࡦͰෛ࠴Λ࡞Γ͜·ͳ͍ํ਑ΛͱΓ͕ͪ
  2. 13.

    σʔλϕʔεͷ7JFX w ਖ਼نԽ͍ͯ͘͠ͱ/ ͷղফ΍+0*/ͷ਺͕ଟͯ͘3BJMT্ͷίʔ υͷݟ௨͕͠ΘΔ͘ͳΔ͜ͱ͕͋Δ w ͦͷͱ͖͸7JFXΛ༻ҙͯ͠ରॲ͢Δ w IUUQTHJUIVCDPNUIPVHIUCPUTDFOJD w

    7JFXΛଟஈʹ͢Δͱ͋Δ7JFXͷߏ੒Λม͍͑ͨͱ͖ʹ໘౗ʹͳ ΔͷͰ஫ҙ w ࣅͨཧ༝ͰΧϥϜ௥Ճ࣌ʹ͜·ΔͷͰ7JFXʹ͸࠷௿ݶͷΧϥϜ Λࢦఆ͢Δ΄͏͕Α͍ w ΞϓϦଆͱ%#ଆʹϩδοΫ͕෼͔ΕΔͷ͸ͪΐͬͱ೰ΈͲ͜Ζ
  3. 16.
  4. 20.

    class Form def sync @model_a = ModelA.new(foo: @foo, bar: @bar)

    @model_b = ModelB.new(hoge: @hoge) end def valid? sync @model_a.valid? && @model_b.valid? end end όϦσʔγϣϯΛͲ͜Ͱߦ͏͔
  5. 21.

    ϑΥʔϜΫϥεʹ௚઀ॻ͘ํ޲ʹγϑτ w ਓ਺΋গͳ͍ͷͰϞσϧ௚઀ݺΜͰόϦσʔγϣϯ͞ΕͣࣄނΔ ͱ͍͏ͷ΋গͳ͍ w ϑΥʔϜ࣮૷͢Δͱ͖ʹϑΥʔϜ୯ҐͰόϦσʔγϣϯߟ͑Δํ ͕ͳΜ͔ϥΫ w ϞσϧͰόϦσʔγϣϯ͢ΔͱࠔΔέʔε΋͋Δ w

    ಛఆΧϥϜ͸ଞͷΧϥϜಉ࢜ͷܭࢉʹΑͬͯຒΊΒΕΔ৔߹ w όϦσʔγϣϯ࣌ʹܭࢉ͢ΔίετΛࢧ෷͏ඞཁ͕͋Δ w ·ͨϑΥʔϜͷ஋ΛόϦσʔγϣϯ͍ͨ͠ͷͰϑΥʔϜͰͦ ͜Λ͋·Γؾʹͨ͘͠ͳ͍
  6. 22.

    class Form def sync @model = ModelA.new(foo: @foo, bar: @bar)

    end def valid? @model.valid? # hogeΛೖΕͯͳ͍ͷͰvalidʹͳΒͳ͍ end def save! hoge = (@foo + @bar) * rate @model.hoge = hoge @model.save! end end