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
920
Kubernetes上で単発のジョブを実行するkube-jobというツールを作った / kubernetesmeetuptokyo22
h3poteto
6
7.9k
Electronによるアプリケーション開発事情2018 / builderscon2018
h3poteto
9
9.5k
fluentdサーバをchefで構築するの辛かったけどDockerも別に救世主じゃなかった / tokyu ruby kaigi 12
h3poteto
0
4.3k
ECSのサービスをslack botでデプロイする // ecs-goploy
h3poteto
1
5k
阿澄佳奈と昇竜拳
h3poteto
1
480
Other Decks in Programming
See All in Programming
Flatt Security XSS Challenge 解答・解説
flatt_security
0
730
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
930
良いユニットテストを書こう
mototakatsu
11
3.6k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
630
AHC041解説
terryu16
0
370
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
770
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.2k
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
560
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
300
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
360
快速入門可觀測性
blueswen
0
500
ATDDで素早く安定した デリバリを実現しよう!
tonnsama
1
1.8k
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
62
7.6k
Mobile First: as difficult as doing things right
swwweet
222
9k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
Producing Creativity
orderedlist
PRO
343
39k
YesSQL, Process and Tooling at Scale
rocio
170
14k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
Typedesign – Prime Four
hannesfritz
40
2.5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
What's in a price? How to price your products and services
michaelherold
244
12k
KATA
mclloyd
29
14k
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ͩʂ
͓ΘΓ