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
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
130
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Jakarta EE meets AI
ivargrimstad
0
570
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
Quine, Polyglot, 良いコード
qnighy
4
640
Macとオーディオ再生 2024/11/02
yusukeito
0
370
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
It's Worth the Effort
3n
183
27k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
A Tale of Four Properties
chriscoyier
156
23k
Embracing the Ebb and Flow
colly
84
4.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Building Your Own Lightsaber
phodgson
103
6.1k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
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/
͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠