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
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Contemporary Test Cases
maaretp
0
140
初めてDefinitelyTypedにPRを出した話
syumai
0
420
React への依存を最小にするフロントエンド設計
takonda
5
1.1k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
cmp.Or に感動した
otakakot
3
210
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
Remix on Hono on Cloudflare Workers
yusukebe
1
300
距離関数を極める! / SESSIONS 2024
gam0022
0
290
みんなでプロポーザルを書いてみた
yuriko1211
0
280
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
GraphQLとの向き合い方2022年版
quramy
43
13k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Code Review Best Practice
trishagee
64
17k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Designing for Performance
lara
604
68k
How STYLIGHT went responsive
nonsquared
95
5.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
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ͩʂ
͓ΘΓ