Slide 1

Slide 1 text

·ͩRailsͰ ফ໣ͯ͠Δͷʁ @h3_poteto

Slide 2

Slide 2 text

About me • ෱ౡ ໌ • CrowdWorksͷRailsΤϯδχΞ • github: h3poteto • twitter: h3_poteto • ޷͖: Ѩ੅Ղಸ

Slide 3

Slide 3 text

·ͩRailsͰ ফ໣ͯ͠Δͷʁ

Slide 4

Slide 4 text

ಥવͰ͕͢ɺ RailsͭΒ͘ͳ͍ʁ

Slide 5

Slide 5 text

CrowdWorksͷRails͸ ͭΒ͍Ͱ͢

Slide 6

Slide 6 text

࠷ۙͷݴಈ • ͜ΕΠϯλʔϑΣʔεΛఆ͍͚ٛͨͩͩ͠ΑͶʁ • ͳΜͰԿ΋ҕৡ͠ͳ͍ͷʹϙϦϞʔϑΟοΫʁ • ໊લม͑Δͱ͔Өڹൣғ޿͗ͯ͢ແཧ • ΍ͬͺܕ͡ΌͶʁ

Slide 7

Slide 7 text

ʊਓਓਓਓਓਓਓਓʊ ʼɹܕ͡ΌͶʁʂɹʻ ʉ̮̮̮̮̮̮̮̮

Slide 8

Slide 8 text

goͷ࿩͔ͳʁ

Slide 9

Slide 9 text

elixirͷ࿩͠·͢

Slide 10

Slide 10 text

͋Μ·Γਂ͍࿩͸͠ͳ͍Ͱ͢

Slide 11

Slide 11 text

RailsΤϯδχΞͷͨΊͷ Phoenixೖ໳

Slide 12

Slide 12 text

elixirͬͯʁ

Slide 13

Slide 13 text

elixir • ErlangVM্Ͱಈ͘ • ؔ਺ܕ • rubyΈ͍ͨͳγϯλοΫε

Slide 14

Slide 14 text

phoenixͬͯʁ

Slide 15

Slide 15 text

phoenix • elixirͷwebϑϨʔϜϫʔΫ • ͍͍ͩͨRails

Slide 16

Slide 16 text

ҰԠίϯύΠϧ͞Ε·͢

Slide 17

Slide 17 text

ܕ͸ͳ͍

Slide 18

Slide 18 text

RailsͰ͍͏˓˓͸ Ͳ͏΍Δͷʁ

Slide 19

Slide 19 text

bundler

Slide 20

Slide 20 text

mix͍ͬͯ͏ͷ͕͋Δ • bundler, rakeΛ߹ΘͤͨΈ͍ͨͳ • mix —help͢ΔͱԿ͕Ͱ͖Δ͔ݟ͑Δ

Slide 21

Slide 21 text

Gemfile

Slide 22

Slide 22 text

mix.exs • ґଘ͢Δhex(rubygems)Λॻ͘ • mix deps.getͯ͠Πϯετʔϧ • lockϑΝΠϧ΋࡞ΒΕΔ(mix.lock)

Slide 23

Slide 23 text

mix.exs

Slide 24

Slide 24 text

mix phoenix.newͨ͠Β ਽ܗ࡞ͬͯ͘Ε·͢

Slide 25

Slide 25 text

mix phoenix.new

Slide 26

Slide 26 text

mix phoenix.server

Slide 27

Slide 27 text

mix phoenix.server • js, cssͷίϯύΠϧ΋ಉ࣌ʹͯ͘͠ΕΔ • devͰ͸Live reload΋ͯ͘͠ΕΔ

Slide 28

Slide 28 text

generate

Slide 29

Slide 29 text

generate • mix phoenix.gen.model ( rails g model ) • mix phoenix.gen.html ( rails g scaffold ) • σΟϨΫτϦߏ੒͸͍͍ͩͨRails

Slide 30

Slide 30 text

σΟϨΫτϦߏ੒

Slide 31

Slide 31 text

ActiveRecord

Slide 32

Slide 32 text

Ecto • elixirͷORM • ͪΐͬͱػೳͷগͳ͍ActiveRecord • has_many, has_one, belongs_to౳΋࢖͑Δ

Slide 33

Slide 33 text

Ecto • schemaͱ͍͏ͷΛఆٛ͢Δ

Slide 34

Slide 34 text

Ecto • where, order, preload

Slide 35

Slide 35 text

routing

Slide 36

Slide 36 text

router.ex • mix phoenix.routesͰ֬ೝͰ͖Δ • จ๏΄΅Rails

Slide 37

Slide 37 text

controller, view(template)

Slide 38

Slide 38 text

΄ͱΜͲRailsͩΖ͜Ε

Slide 39

Slide 39 text

eex(erb)

Slide 40

Slide 40 text

ςετ

Slide 41

Slide 41 text

ExUnit • phoenixʹඪ४Ͱ͍ͭͯ͘Δςετ • Ϣχοτςετ͕Ͱ͖Δ • setup, setup_allʢRSpecͷbeforeͱ͸ͪΐͬ ͱҧ͏ • describe͸͋Δ

Slide 42

Slide 42 text

ESpec • RSpecΈ͍ͨͳ…… • จ๏΄΅RSpec • before, let, describe, context…

Slide 43

Slide 43 text

ESpec

Slide 44

Slide 44 text

خ͔ͬͨ͜͠ͱ

Slide 45

Slide 45 text

sprockets͕ͳ͍

Slide 46

Slide 46 text

Sprocketsͱ͍͑͹…… • node͕ϝδϟʔ͡Όͳ͍࣌୅ʹΑ͘ؤுͬͨ • helperͱͷ૬ੑ΋ྑ͍ • precompileͯ͘͠ΕΔ

Slide 47

Slide 47 text

Ͱ΋࠷ۙͭΒ͍

Slide 48

Slide 48 text

ES6࢖͍͍ͨ

Slide 49

Slide 49 text

React࢖͍͍ͨ

Slide 50

Slide 50 text

browserifyͲ͏͠Α͏

Slide 51

Slide 51 text

npm͕͍͍……

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

phoenixͷϑϩϯτΤϯυ • npmʹ৐͔ͬΔ • branchͰτϥϯεύΠϧ͍ͯ͠Δ • gulpͱ͔webpackʹมߋՄೳ

Slide 54

Slide 54 text

phoenixͷϑϩϯτΤϯυ • devͰ͸มߋݕ஌ʴLive Reload • mix phoenix.serverίϚϯυͰશ෦΍ͬͯ͘Ε Δ • ຊ൪༻ʹ͸ɺmix phoenix.digest ( assets:precompile )

Slide 55

Slide 55 text

ඇಉظॲཧ

Slide 56

Slide 56 text

RailsͰඇಉظॲཧͬͯʁ • DelayedJobʢCrowdWorksͰ࢖ͬͯΔ • Resque • Sidekiq • ShoryukenʢCrowdWorksͰ࢖ͬͯΔ

Slide 57

Slide 57 text

͍ͣΕʹͯ͠΋ ϫʔΧʔΛผϓϩηεͰཱͪ ্͓͛ͯ͘

Slide 58

Slide 58 text

Ωϡʔ΋redisͱ͔ࣗ෼Ͱ ༻ҙ͢Δ

Slide 59

Slide 59 text

elixirͷඇಉظॲཧ • ͦ΋ͦ΋ܰྔϓϩηεͰಈ͍ͯΔ • OTP(actorͬΆ͍΍ͭ) • ৽͍͠ϓϩηε্ཱͪ͛ͯɺϝοηʔδΛૹ Ζ͏

Slide 60

Slide 60 text

elixirͷඇಉظॲཧ • Taskͱ͔Agentͱ͍͏ͷ͕ͦ΋ͦ΋༻ҙ͞Εͯ ͍Δ • όοΫάϥ΢ϯυॲཧΛ͚ͨ͠Ε͹Taskʹ౤ ͛Δ͚ͩ

Slide 61

Slide 61 text

elixirͷඇಉظॲཧ • ݁ՌΛ଴ͪड͚Δ͜ͱ΋Ͱ͖Δʢ଴ͨͳͯ͘ ΋͍͍

Slide 62

Slide 62 text

elixirͷඇಉظॲཧ • ϓϩηεͷϦϯΫ • ࢠ͕ࢮΜͩͱ͖ʹ਌΋ࢮ͵ • ࢠ͕ࢮΜͰ΋਌͸Կ΋஌Β͞Εͳ͍ • ࢠ͕ࢮΜͩΒ਌ʹ௨஌͚ͩ͸ߦ͘

Slide 63

Slide 63 text

Railsʹൺ΂Δͱ • Ωϡʔͷ؅ཧΛ͠ͳ͍͍ͯ͘ • sidekiqͱ͔ϓϩηεΛੜ͔͢͜ͱʹؾΛ࢖Θ ͳ͍͍ͯ͘ • ͦ΋ͦ΋Railsͬͯͦ͜·ͰεϨουηʔϑ ͡Όͳ͍Ͱ͠ΐ

Slide 64

Slide 64 text

shoryukenͷίϛολʔͱઓ Θͳͯ͘΋͍͍!!!

Slide 65

Slide 65 text

ϙϦϞʔϑΟοΫ

Slide 66

Slide 66 text

RailsͷϙϦϞʔϑΟοΫ • ActiveRecord͕༻ҙͯ͘͠ΕͯΔ • **able_id, **able_typeͰDBςʔϒϧͷؔ࿈Λ ࡞ͬͯ͘ΕΔ

Slide 67

Slide 67 text

ศརͳ͜ͱ΋͋Δ

Slide 68

Slide 68 text

Ͱ΋୯७ʹΫϥεʹ ΠϯλʔϑΣʔεΛఆٛͨ͠ ͍ͱ͖΋͋Δ

Slide 69

Slide 69 text

elixirͷprotocol • protocol͕ఆٛͰ͖Δ • ଴๬ͷΠϯλʔϑΣʔεͩΑʂʂʂ

Slide 70

Slide 70 text

ظ଴

Slide 71

Slide 71 text

modelͱschema ෼཭͢ΔͬͯΑ

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

RailsͰݴ͏ͱɺ model͕ActiveRecord͔Β ੾Γ཭͞ΕΔ

Slide 74

Slide 74 text

ࣾ಺αʔϏε࡞ͬͯΔ

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Yadockeri • ࣾ಺herokuΈ͍ͨͳ • CrowdWorksͷDockerίϯςφΛDocker swarm্ʹσϓϩΠ͢Δ • WebUIͱAPIΛ࡞੒

Slide 77

Slide 77 text

·ͱΊ • ͋·Γ෭࡞༻ͷ͋ΔϝιουΛॻ͘ؾʹͳΕ ͳ͍ • ΦϒδΣΫτͱ͔ͳ͍͠Ͷʂ • Ͱ΋τϥϯβΫγϣϯॻ͖࢝ΊΔͱؔ਺ײθϩ • sprocketsͳͲͳ͍ɺશ෦npmͩʂ

Slide 78

Slide 78 text

͓ΘΓ