Slide 1

Slide 1 text

RailsΛֶͼɺݱ৔ʹೖΔ·Ͱ RAILS DEVELOPERS MEETUP 2017 LT @KOJI MIKAMI

Slide 2

Slide 2 text

ࠓ೔࿩͢͜ͱ

Slide 3

Slide 3 text

֓ཁ Railsྺ = ΤϯδχΞྺ

Slide 4

Slide 4 text

֓ཁ RailsΛֶͼɺݱ৔ʹೖΔ·Ͱ ▸ νϡʔτϦΞϧԿप͔΍ΔˠݸਓͰΞϓϦέʔγϣϯॻ͍ͯΈΔ ▸ ݱ৔ʹೖΔˠ͍͔ͭ͘ͷนʹͿͪ౰ͨΔ ▸ Ͳ͜Ͱͭ·ͮ͘ͷ͔ ▸ ϝϯλʔ΍·ΘΓͷϝϯόʔ͸Ͳ͜ΛϑΥϩʔ͢Ε͹Α͍ͷ͔ ▸ ࢲ͕Ϳ͔ͭͬͨนΛέʔεελσΟͰ͓ૹΓ͠·͢

Slide 5

Slide 5 text

ຊ୊ Զ͕Ϳ͔ͭͬͨนʢ࣮࿩ʣ ▸ ίʔυϨϏϡʔ͕௨Βͳ͍ ৽ػೳ࣮૷͢Δͧʂ

Slide 6

Slide 6 text

ຊ୊ Զ͕Ϳ͔ͭͬͨน ▸ ίʔυϨϏϡʔ͕௨Βͳ͍ Ͳ͏͍͏ઃܭ͕ ͍͍Μͩʂ

Slide 7

Slide 7 text

ຊ୊ Զ͕Ϳ͔ͭͬͨน ▸ ίʔυϨϏϡʔ͕௨Βͳ͍ ࣮૷ऴΘͬͨʂ PRग़ͧ͢ʂ

Slide 8

Slide 8 text

ຊ୊ Զ͕Ϳ͔ͭͬͨน ▸ ίʔυϨϏϡʔ͕௨Βͳ͍

Slide 9

Slide 9 text

ຊ୊ Զ͕Ϳ͔ͭͬͨน ▸ ίʔυϨϏϡʔ͕௨Βͳ͍ ίϝϯτ͕ͨ͘͞Μ෇͍ͯർฐ…

Slide 10

Slide 10 text

ຊ୊ Զ͕Ϳ͔ͭͬͨน ▸ Ͳ͏ͯ͜͠Μͳʹίϝϯτ͕෇͍ͨͷ͔ ▸ ActiveRecordΛ͏·͘࢖͍͑ͯͳ͍ ▸ Ͳ͜ʢMVC, etc…ʣʹͲ͏࣮૷͢Δͷ͕ྑ͍͔͋΍;΍ʹͳͬ ͍ͯΔ

Slide 11

Slide 11 text

Զ͕Ϳ͔ͭͬͨน ▸ ActiveRecordΛ͏·͘࢖͍͑ͯͳ͍ ▸ N+1ΫΤϦΛ࡞͍ͬͯΔʢద੾ʹϩʔυͰ͖͍ͯͳ͍ʣ ▸ ςΩτʔʹincludes͢Δ
 k0kubun͞ΜͷʮActiveRecordͷjoinsͱpreloadͱincludesͱeager_loadͷҧ͍ʯΛಡΈ· ͠ΐ͏ https://qiita.com/k0kubun/items/80c5a5494f53bb88dc58 Case 1.

Slide 12

Slide 12 text

Զ͕Ϳ͔ͭͬͨน ▸ Ͳ͜ʹ࣮૷͢Δ͔Ͱ೰Ή ▸ ActiveRecordʹҾ͖ͮΒΕΔ ▸ σϑΥϧτͷϨΠϠʔͱͷҧ͍ Case 1.

Slide 13

Slide 13 text

Case 2. ActiveRecordܧঝ͠ͳͯ͘΋ྑ͍ͷ͔Α ▸ ActiveRecordύλʔϯ
 σʔλϕʔεͷςʔϒϧ΍ϏϡʔͷྻΛϥοϓ͠ɺσʔλϕʔεΞΫηεΛΧϓ ηϧԽ͠ɺυϝΠϯϩδοΫΛ௥Ճ͢ΔΦϒδΣΫτ[1] [1] http://bliki-ja.github.io/pofeaa/ActiveRecord/ Ϟσϧ = ActiveRecordΛඞͣܧঝ ςʔϒϧ : Ϟσϧͩͱࢥͬͯ͠·͏

Slide 14

Slide 14 text

ActiveRecordΛܧঝ͠ͳ͍ϞσϧΛ࡞ͬͯ΋ྑ͍ ▸ ςʔϒϧͷͳ͍FormͰActiveModelϞδϡʔϧΛ࢖͏ ▸ ActiveModel::ValidatorΫϥεΛ࢖ͬͯόϦσʔλΛ෼཭͢Δ ▸ Ϣʔεέʔεͱͯ͠ߟ͑Δ
 →ςʔϒϧͱ1:1Ͱඥ෇͔ͳ͍ϞσϦϯάʹͭͳ͕Δ
 →αʔϏεΦϒδΣΫτͱͯ͠෼཭͢Δͷ΋͋Γ ৄ͘͠͸joker͞ΜͷʮͯΊ͑ΒͷRails͸ΦϒδΣΫτࢦ޲͡ΌͶ͑ʂ·ͣ͸CallbackΫϥεɺValidatorΫϥεΛ׆༻͠ ΖʂʯΛಡΜͰΈ͍ͯͩ͘͞ https://qiita.com/joker1007/items/2a03500017766bdb0234 Case 2.

Slide 15

Slide 15 text

ϓϩδΣΫτͰαʔϏεΦϒ δΣΫτಋೖͯ͠Δਓʁ Case 2.

Slide 16

Slide 16 text

ϨΠϠʔͰ೰Ή Case 3. rails new ྫ: Ϛετυϯ

Slide 17

Slide 17 text

ϨΠϠʔͰ೰Ή ྫ: Ϛετυϯ Զͷ஌ͬͯΔߏ଄͡Όͳ͍… rails new Case 3.

Slide 18

Slide 18 text

σϑΥϧτͷ··։ൃ͢ΔϝϦοτ ▸ νʔϜͰೝࣝΛἧ͑΍͍͢ ▸ ࣮૷ՕॴͰ೰Ή͕࣌ؒݮΔ ▸ ϨʔϧΛ֎Εʹ͍͘ Case 3.

Slide 19

Slide 19 text

ϨΠϠʔΛ௥Ճ͢ΔϝϦοτ ▸ ϑΝοτϞσϧɺϑΝοτίϯτϩʔϥʔΛճආ ▸ ςετॻ͖΍͍͢ ▸ ϝϯς͠΍͍͢ Case 3.

Slide 20

Slide 20 text

ϦʔυΤϯδχΞʹઃܭͷҙਤΛฉ͜͏ Case 3.

Slide 21

Slide 21 text

͓ΘΓʹ ݁࿦ ‣ joker͞ΜͷʮԶ͕ѱ͔ͬͨɻૉ௚ʹؒҧ͍ΛೝΊΔ͔Βɺ΋͏αʔϏεΫϥεͱ͔࡞ Δͷ͸ࢭΊͯ͘ΕʯΛಡΉ
 https://qiita.com/joker1007/items/25de535cd8bb2857a685 ‣ onk͞Μͷʮ;ͭ͏ͷRailsΞϓϦέʔγϣϯ։ൃʯΛݟΔ
 railsdm#2ͷൃදͰ͢Ͷ
 https://www.slideshare.net/takafumionaka/rails-77195340 ‣ Sandi MetzͷʮΦϒδΣΫτࢦ޲ઃܭ࣮ફΨΠυʯΛಡΉ

Slide 22

Slide 22 text

THANK YOU!!