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
#UV_study_20210629
Search
Shiro Tamaki
June 29, 2021
Programming
0
250
#UV_study_20210629
【初心者歓迎】Ruby LT会@オンライン \- connpass
(
https://uniquevision.connpass.com/event/215217/
)
Shiro Tamaki
June 29, 2021
Tweet
Share
More Decks by Shiro Tamaki
See All by Shiro Tamaki
kakutanitalk2022_opening_act
shirotamaki
0
740
fjordbootcamp_20210424
shirotamaki
0
940
fjordbootcamp_20210424_mc_slide
shirotamaki
0
800
Other Decks in Programming
See All in Programming
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
初めてDefinitelyTypedにPRを出した話
syumai
0
400
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
Jakarta EE meets AI
ivargrimstad
0
140
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Ethereum_.pdf
nekomatu
0
460
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
Realtime API 入門
riofujimon
0
150
Arm移行タイムアタック
qnighy
0
320
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
How GitHub (no longer) Works
holman
310
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Transcript
1 SinatraΛͬͯ ॳΊͯWebΞϓϦΛ࡞ͬͯΈͨ @shirotamaki 2021, 6, 29 (Tue) ɹRuby LTձ@ΦϯϥΠϯ
ओ࠵ : ϢχʔΫϏδϣϯגࣜձ༷ࣾ ʮRubyΫοΩϯάʯ
˙͘͡ 2 • ࣗݾհ • ࡞ΔϝχϡʔɺࡐྉͳͲͷհ • ࡐྉʹ͍ͭͯਂງΓ • ࡞Γํ
˙ࣗݾհ @shirotamaki ɹ ۄ ࢤ ϑΟϤϧυϒʔτΩϟϯϓ32ظੜ Rubyྺ: 6ϲ݄ 3
˙RubyͰ࡞Δϝχϡʔ 4 JSONͱHashΛͬͨSinatra࢈ ϝϞΞϓϦ
˙ࡐྉ * JSONϑΝΠϧ * HashΦϒδΣΫτ 5 ˙༻ҙ͢Δͷ • Ruby 3.0.0
• Sinatra
˙ௐຯྉ * params ϋογϡ ɹ * JSON.parseϞδϡʔϧؔ * JSON.dumpϞδϡʔϧؔ 6
˙ਂງΓ
˙Sinatraʢγφτϥʣ 8 RubyͷWebΞϓϦέʔγϣϯϑϨʔϜϫʔΫͰ͢ɻ هड़༰͕؆ܿͰ͔Γ͘͢ͱ͍ͯܰͷ͕ಛͰ͢ɻ ͦͷͨΊɺখنͳΞϓϦέʔγϣϯΛ࡞͢Δͷʹ ͍͍ͯ·͢ɻ
˙JSONʢδΣΠιϯʣ 9 JavaScript Object Notationͷུ ߏԽͨ͠σʔλΛදͨ͢ΊͷςΩετϑΥʔϚοτͷҰछͰ͢ɻ JavaScript͚ͩͰͳ͘ɺଟ͘ͷϓϩάϥϛϯάݴޠWebαʔϏε ʹରԠ͍ͯ͠·͢ɻ ઃఆϑΝΠϧσʔλަͳͲΛ͢Δͱ͖ʹΑ͘ΘΕ͍ͯ·͢ɻ ϑΝΠϧ໊ʮKTPOʯɹ
˞σʔλϕʔεͷཧJSONϑΝΠϧΛར༻͠·͢ɻ ɹࠓճɺActiveRecordར༻͠·ͤΜɻ
˙JSON͕ରԠ͍ͯ͠Δσʔλܕ 10 JSONʹΈࠐΈͰ༻ҙ͞Ε͍ͯΔσʔλܕ̒ͭ * ΦϒδΣΫτ * ྻ * จࣈྻ *
* ϒʔϦΞϯ * null
˙Hashʢϋογϡʣ 11 ϋογϡɺʮΩʔʯͱʮʯͷηοτͰσʔλΛཧ͢Δ ΦϒδΣΫτͷ͜ͱͰ͢ɻ ଞͷݴޠͰʮ࿈ྻʯʮࣙॻʯʮϚοϓʯͱݺΕͨΓ ͠·͢ɻ ӳޠͷHashɺίϚΕͱࡊΛᖱΊͨྉཧͷࣄΛࢦ͠ɺ ϋογϡυϏʔϑͷޠݯͰ͋Γ·͢ɻ
˙Hashͷ2ͭͷॻ͖ํ 12 ϋογϡϩέοτ ͬͨॻ͖ํ ϋογϡϩέοτΛলུͨ͠ॻ͖ํ
˙Ruby ΫοΩϯάελʔτʂ 13
14 ˙·ͣɺrequireͰԼ͝͠Β͑
˙৽نϝϞೖྗը໘ͷϧʔςΟϯά 15
˙ڞ௨͢ΔϨΠΞτΛ·ͱΊΔ 16 index.erb new.erb
17 ˙formλάͰೖྗɾૹ৴ϑΥʔϜΛ࡞͢Δ
˙్தܦաɺHTMLΛϨϯμϦϯάʢը૾Λੜʣ 18
˙HashΛJSONม͠ϑΝΠϧΛอଘ͢Δ 19 JSON Hash JSON.dump
˙JSONϑΝΠϧͱͯ͠ɺdbσΟϨΫτϦอଘ͢Δ 20
˙ϝϞҰཡදࣔ༻ͷϧʔςΟϯά 21 JSON Hash JSON.parse
˙Ұཡදࣔ༻ͷerbΛ࡞͢Δ 22
˙πϦʔߏ 23
˙URLΞΫηεͯ͠ΈΔ 24
˙ग़དྷ্͕Γʂ 25
˙ࢀߟهࣄɾࢀߟॻ੶ 26 ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ https:/ /docs.ruby-lang.org/ja/(ࢀর2021,6,28) Sinatra: README http:/
/sinatrarb.com/intro-ja.html/(ࢀর2021.6.28) ϦϒϩϫʔΫε ஶ/ߴڮ ٛ म/ʰεϥεϥಡΊΔ Ruby;Γ͕ͳϓϩάϥϛϯά ʱ/ΠϯϓϨεϒοΫε/2019 ޒेཛྷ໌ɼদԬߒฏ ஶ/ʰθϩ͔ΒΘ͔Δ Ruby ೖʱ/ٕज़ධࣾ/2018 ߴڮٛɺޙ౻༟ଂ ஶ/ʰͨͷ͍͠Rubyୈ6൛ʱ/SBΫϦΤΠςΟϒ/2019 ҏ౻३Ұ ஶ/ʰϓϩΛࢦ͢ਓͷͨΊͷRubyೖ ݴޠ༷͔Βςετۦಈ։ൃɾσόοάٕ๏·Ͱʱ/ٕज़ධࣾ/ 2017 ࢁຊཅฏஶ/ ʰWebΛࢧ͑Δٕज़ɹHTTP, URI, HTML, ͦͯ͠RESTʱ/ٕज़ධࣾ/2010
˙ϒϩάͬͯ·͢ 27 ͯͳϒϩά D IT YɹλϚΩళͷITه https:/ /shirotamaki.hatenablog.com/
͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠