Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
まだRailsで消耗してるの?
Search
h3poteto
October 25, 2016
Programming
7
4.7k
まだRailsで消耗してるの?
https://cw-meetup.doorkeeper.jp/events/52879
での発表資料
h3poteto
October 25, 2016
Tweet
Share
More Decks by h3poteto
See All by h3poteto
EKS on Fargateは最高のJob基盤 / jawsug_bgnr
h3poteto
1
880
Kubernetes上で単発のジョブを実行するkube-jobというツールを作った / kubernetesmeetuptokyo22
h3poteto
6
7.6k
Electronによるアプリケーション開発事情2018 / builderscon2018
h3poteto
9
9.3k
fluentdサーバをchefで構築するの辛かったけどDockerも別に救世主じゃなかった / tokyu ruby kaigi 12
h3poteto
0
4k
ECSのサービスをslack botでデプロイする // ecs-goploy
h3poteto
1
4.8k
阿澄佳奈と昇竜拳
h3poteto
1
460
Other Decks in Programming
See All in Programming
Why Prism?
kddnewton
4
1.7k
Pythonで改めて考える「クラス(class)」の使いどころ
os1ma
2
710
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
810
Understand the mechanism! Let's do screenshots tests of Compose Previews with various variations / 仕組みから理解する!Composeプレビューを様々なバリエーションでスクリーンショットテストしよう
sumio
3
810
rbs-inlineを導入してYARDからRBSに移行する
euglena1215
1
290
What you can do with Ruby on WebAssembly
kateinoigakukun
0
170
はじめてみよう量子プログラミング
itokoichi01
0
210
エラーレスポンス設計から考える、0→1開発におけるGraphQLへの向き合い方
bicstone
5
1.5k
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
2
120
Findy - エンジニア向け会社紹介 / Findy Letter for Engineers
findyinc
4
90k
LangChainの現在とv0.3にむけて
os1ma
4
930
【TID2024】模擬講義:プログラマと一緒にゲームをデザインしてみよう!
akatsukigames_tech
0
660
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
64
11k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
4 Signs Your Business is Dying
shpigford
179
21k
Fontdeck: Realign not Redesign
paulrobertlloyd
80
5.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
248
20k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
41
6.5k
Designing with Data
zakiwarfel
98
5k
In The Pink: A Labor of Love
frogandcode
139
22k
The Cost Of JavaScript in 2023
addyosmani
42
5.7k
Adopting Sorbet at Scale
ufuk
73
8.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
5
480
Learning to Love Humans: Emotional Interface Design
aarron
270
40k
Transcript
·ͩRailsͰ ফͯ͠Δͷʁ @h3_poteto
About me • ౡ ໌ • CrowdWorksͷRailsΤϯδχΞ • github: h3poteto
• twitter: h3_poteto • ͖: ѨՂಸ
·ͩRailsͰ ফͯ͠Δͷʁ
ಥવͰ͕͢ɺ RailsͭΒ͘ͳ͍ʁ
CrowdWorksͷRails ͭΒ͍Ͱ͢
࠷ۙͷݴಈ • ͜ΕΠϯλʔϑΣʔεΛఆ͍͚ٛͨͩͩ͠ΑͶʁ • ͳΜͰԿҕৡ͠ͳ͍ͷʹϙϦϞʔϑΟοΫʁ • ໊લม͑Δͱ͔Өڹൣғ͗ͯ͢ແཧ • ͬͺܕ͡ΌͶʁ
ʊਓਓਓਓਓਓਓਓʊ ʼɹܕ͡ΌͶʁʂɹʻ ʉ̮̮̮̮̮̮̮̮
goͷ͔ͳʁ
elixirͷ͠·͢
͋Μ·Γਂ͍͠ͳ͍Ͱ͢
RailsΤϯδχΞͷͨΊͷ Phoenixೖ
elixirͬͯʁ
elixir • ErlangVM্Ͱಈ͘ • ؔܕ • rubyΈ͍ͨͳγϯλοΫε
phoenixͬͯʁ
phoenix • elixirͷwebϑϨʔϜϫʔΫ • ͍͍ͩͨRails
ҰԠίϯύΠϧ͞Ε·͢
ܕͳ͍
RailsͰ͍͏˓˓ Ͳ͏Δͷʁ
bundler
mix͍ͬͯ͏ͷ͕͋Δ • bundler, rakeΛ߹ΘͤͨΈ͍ͨͳ • mix —help͢ΔͱԿ͕Ͱ͖Δ͔ݟ͑Δ
Gemfile
mix.exs • ґଘ͢Δhex(rubygems)Λॻ͘ • mix deps.getͯ͠Πϯετʔϧ • lockϑΝΠϧ࡞ΒΕΔ(mix.lock)
mix.exs
mix phoenix.newͨ͠Β ܗ࡞ͬͯ͘Ε·͢
mix phoenix.new
mix phoenix.server
mix phoenix.server • js, cssͷίϯύΠϧಉ࣌ʹͯ͘͠ΕΔ • devͰLive reloadͯ͘͠ΕΔ
generate
generate • mix phoenix.gen.model ( rails g model ) •
mix phoenix.gen.html ( rails g scaffold ) • σΟϨΫτϦߏ͍͍ͩͨRails
σΟϨΫτϦߏ
ActiveRecord
Ecto • elixirͷORM • ͪΐͬͱػೳͷগͳ͍ActiveRecord • has_many, has_one, belongs_to͑Δ
Ecto • schemaͱ͍͏ͷΛఆٛ͢Δ
Ecto • where, order, preload
routing
router.ex • mix phoenix.routesͰ֬ೝͰ͖Δ • จ๏΄΅Rails
controller, view(template)
΄ͱΜͲRailsͩΖ͜Ε
eex(erb)
ςετ
ExUnit • phoenixʹඪ४Ͱ͍ͭͯ͘Δςετ • Ϣχοτςετ͕Ͱ͖Δ • setup, setup_allʢRSpecͷbeforeͱͪΐͬ ͱҧ͏ •
describe͋Δ
ESpec • RSpecΈ͍ͨͳ…… • จ๏΄΅RSpec • before, let, describe, context…
ESpec
خ͔ͬͨ͜͠ͱ
sprockets͕ͳ͍
Sprocketsͱ͍͑…… • node͕ϝδϟʔ͡Όͳ͍࣌ʹΑ͘ؤுͬͨ • helperͱͷ૬ੑྑ͍ • precompileͯ͘͠ΕΔ
Ͱ࠷ۙͭΒ͍
ES6͍͍ͨ
React͍͍ͨ
browserifyͲ͏͠Α͏
npm͕͍͍……
None
phoenixͷϑϩϯτΤϯυ • npmʹ͔ͬΔ • branchͰτϥϯεύΠϧ͍ͯ͠Δ • gulpͱ͔webpackʹมߋՄೳ
phoenixͷϑϩϯτΤϯυ • devͰมߋݕʴLive Reload • mix phoenix.serverίϚϯυͰશ෦ͬͯ͘Ε Δ • ຊ൪༻ʹɺmix
phoenix.digest ( assets:precompile )
ඇಉظॲཧ
RailsͰඇಉظॲཧͬͯʁ • DelayedJobʢCrowdWorksͰͬͯΔ • Resque • Sidekiq • ShoryukenʢCrowdWorksͰͬͯΔ
͍ͣΕʹͯ͠ ϫʔΧʔΛผϓϩηεͰཱͪ ্͓͛ͯ͘
Ωϡʔredisͱ͔ࣗͰ ༻ҙ͢Δ
elixirͷඇಉظॲཧ • ͦͦܰྔϓϩηεͰಈ͍ͯΔ • OTP(actorͬΆ͍ͭ) • ৽͍͠ϓϩηε্ཱͪ͛ͯɺϝοηʔδΛૹ Ζ͏
elixirͷඇಉظॲཧ • Taskͱ͔Agentͱ͍͏ͷ͕ͦͦ༻ҙ͞Εͯ ͍Δ • όοΫάϥϯυॲཧΛ͚ͨ͠ΕTaskʹ ͛Δ͚ͩ
elixirͷඇಉظॲཧ • ݁ՌΛͪड͚Δ͜ͱͰ͖Δʢͨͳͯ͘ ͍͍
elixirͷඇಉظॲཧ • ϓϩηεͷϦϯΫ • ࢠ͕ࢮΜͩͱ͖ʹࢮ͵ • ࢠ͕ࢮΜͰԿΒ͞Εͳ͍ • ࢠ͕ࢮΜͩΒʹ௨͚ͩߦ͘
RailsʹൺΔͱ • ΩϡʔͷཧΛ͠ͳ͍͍ͯ͘ • sidekiqͱ͔ϓϩηεΛੜ͔͢͜ͱʹؾΛΘ ͳ͍͍ͯ͘ • ͦͦRailsͬͯͦ͜·ͰεϨουηʔϑ ͡Όͳ͍Ͱ͠ΐ
shoryukenͷίϛολʔͱઓ Θͳ͍͍ͯ͘!!!
ϙϦϞʔϑΟοΫ
RailsͷϙϦϞʔϑΟοΫ • ActiveRecord͕༻ҙͯ͘͠ΕͯΔ • **able_id, **able_typeͰDBςʔϒϧͷؔ࿈Λ ࡞ͬͯ͘ΕΔ
ศརͳ͜ͱ͋Δ
Ͱ୯७ʹΫϥεʹ ΠϯλʔϑΣʔεΛఆٛͨ͠ ͍ͱ͖͋Δ
elixirͷprotocol • protocol͕ఆٛͰ͖Δ • ͷΠϯλʔϑΣʔεͩΑʂʂʂ
ظ
modelͱschema ͢ΔͬͯΑ
None
RailsͰݴ͏ͱɺ model͕ActiveRecord͔Β Γ͞ΕΔ
ࣾαʔϏε࡞ͬͯΔ
None
Yadockeri • ࣾherokuΈ͍ͨͳ • CrowdWorksͷDockerίϯςφΛDocker swarm্ʹσϓϩΠ͢Δ • WebUIͱAPIΛ࡞
·ͱΊ • ͋·Γ෭࡞༻ͷ͋ΔϝιουΛॻ͘ؾʹͳΕ ͳ͍ • ΦϒδΣΫτͱ͔ͳ͍͠Ͷʂ • ͰτϥϯβΫγϣϯॻ͖࢝ΊΔͱؔײθϩ • sprocketsͳͲͳ͍ɺશ෦npmͩʂ
͓ΘΓ