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
760
fjordbootcamp_20210424
shirotamaki
0
950
fjordbootcamp_20210424_mc_slide
shirotamaki
0
810
Other Decks in Programming
See All in Programming
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
300
AHC041解説
terryu16
0
370
2025.01.17_Sansan × DMM.swift
riofujimon
2
540
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
410
令和7年版 あなたが使ってよいフロントエンド機能とは
mugi_uno
10
5.1k
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
4
1.1k
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
420
ASP.NET Core の OpenAPIサポート
h455h1
0
110
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
180
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
240
functionalなアプローチで動的要素を排除する
ryopeko
1
190
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
521
39k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Six Lessons from altMBA
skipperchong
27
3.6k
The World Runs on Bad Software
bkeepers
PRO
66
11k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Fireside Chat
paigeccino
34
3.1k
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/
͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠