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
900
Kubernetes上で単発のジョブを実行するkube-jobというツールを作った / kubernetesmeetuptokyo22
h3poteto
6
7.7k
Electronによるアプリケーション開発事情2018 / builderscon2018
h3poteto
9
9.4k
fluentdサーバをchefで構築するの辛かったけどDockerも別に救世主じゃなかった / tokyu ruby kaigi 12
h3poteto
0
4.2k
ECSのサービスをslack botでデプロイする // ecs-goploy
h3poteto
1
4.9k
阿澄佳奈と昇竜拳
h3poteto
1
470
Other Decks in Programming
See All in Programming
RubyLSPのマルチバイト文字対応
notfounds
0
110
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
120
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
550
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Java ジェネリクス入門 2024
nagise
0
720
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.8k
EventSourcingの理想と現実
wenas
6
2.3k
ヤプリ新卒SREの オンボーディング
masaki12
0
120
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
Ethereum_.pdf
nekomatu
0
450
subpath importsで始めるモック生活
10tera
0
260
Amazon Qを使ってIaCを触ろう!
maruto
0
390
Featured
See All Featured
Statistics for Hackers
jakevdp
796
220k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
GitHub's CSS Performance
jonrohan
1030
460k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Pragmatic Product Professional
lauravandoore
31
6.3k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Scaling GitHub
holman
458
140k
Optimizing for Happiness
mojombo
376
70k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Speed Design
sergeychernyshev
24
610
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ͩʂ
͓ΘΓ