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
Putting CRUD to REST: An Introduction to RESTfu...
Search
Viking Education
July 17, 2015
Technology
660
1
Share
Putting CRUD to REST: An Introduction to RESTful Routing by Dan Berger
Viking Education
July 17, 2015
More Decks by Viking Education
See All by Viking Education
Getting a Developer Job with a Non-Traditional Background
vikingeducation
1
1.7k
AirBnB Teardown: Behdad A.
vikingeducation
0
430
Viking Code School Presents Christopher Hendrix of Pivotal Labs
vikingeducation
0
190
Viking Blogger Demo: Design Phase
vikingeducation
2
3.5k
UX Teardown of Soundcloud
vikingeducation
0
3.2k
A Design Teardown of DN.se
vikingeducation
1
3.9k
Viking Blogger Demo: Introduction
vikingeducation
0
4.1k
Viking Blogger Demo: Discovery Phase
vikingeducation
0
4.1k
vb_3_strategy_phase_slides_pdf.pdf
vikingeducation
0
4k
Other Decks in Technology
See All in Technology
大規模環境でどのように監視を実現する?
yuobayashi
1
140
Pythonでベイズモデリング
soogie
0
180
開発にAIを組織として取り入れる一歩目とその後
yujishibuya
0
210
業務に残された「良くない型」で考える「TypeScriptの難しさ」
sajikix
3
2k
その英語学習、AWSで代替できませんか?
suzutatsu
1
240
ジュニアエンジニアはSREとどう向き合うべきか
nrinetcom
PRO
1
120
脅威をエンジニアリングの糧にして:恐怖を乗り越えた先にあったもの / Turn threats into fuel for engineering: what lay beyond overcoming fear
nrslib
0
200
生成AIに振り回されない 〜確率論と決定論の使い分け〜
shukob
0
100
Loadbalancing exporter internals
ymotongpoo
1
130
LLM時代のリファクタリング戦略_AIエージェントによる段階的・安全なTS移行方法
play_inc
0
180
キャリア25年目にしてTypeScript に出会うまで - 「型」を通じて振り返るプログラミング言語遍歴 / Meeting TypeScript After 25 Years in Tech - Looking Back at My Programming Language Journey Through "Types"
bitkey
PRO
2
270
Amazon CloudFrontにおけるAIボットアクセス制御のポイント
kizawa2020
4
260
Featured
See All Featured
From π to Pie charts
rasagy
0
190
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
WCS-LA-2024
lcolladotor
0
600
So, you think you're a good person
axbom
PRO
2
2k
Faster Mobile Websites
deanohume
310
31k
Google's AI Overviews - The New Search
badams
0
1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Statistics for Hackers
jakevdp
799
230k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
300
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
240
Writing Fast Ruby
sferik
630
63k
Transcript
Putting CRUD to REST
Goals - Briefly introduce you to Representational State Transfer, or
REST. - Give you a mental model for relating RESTful controller actions to CRUD principles.
Quick CRUD review - Create - Read - Update -
Delete
Read: Index & Show actions - Index reads all the
instances of this object. - @foos = Foo.all - Show reads one instance of this object. - @foo = Foo.find(params[:id]) - They are both HTML ‘get’ actions.
CRUD REST HTML Create Read index get show get Update
Delete
Create: New controller action - HTML ‘get’ request from browser
- Controller creates an empty object: - @foo = Foo.new - Controller sends “new” view to browser.
Create: Create controller action - HTML ‘post’ request from browser
- Controller creates an object with attributes: - @foo = Foo.new(params) - Controller saves the new object: - @foo.save
Create: full circle NEW ‘get’ the view and empty object
Controller CREATE ‘post’ the form params to the object and save
CRUD REST HTML Create new get create post Read index
get show get Update Delete
Update: Edit controller action - HTML ‘get’ request from browser
- Controller finds the target object in DB: - @foo = Foo.find(params[:id]) - Controller sends “edit” view to browser with complete params.
Update: Update controller action - HTML ‘put’ request from browser
- Controller updates the object’s attributes: - @foo = Foo.update(params) - Controller saves the object: - @foo.save
Update: full circle EDIT ‘get’ the view and object attributes
Controller UPDATE ‘put’ the form params to the object and save
CRUD REST HTML Create new get create post Read index
get show get Update edit get update put Delete
Delete: Destroy controller action - HTML ‘destroy’ request from browser
- actually a ‘get’ request with { method: delete } options hash - Controller finds the target object in DB: - @foo = Foo.find(params[:id]) - DESTROY!!!! - @foo.destroy
CRUD REST HTML Create new get create post Read index
get show get Update edit get update put Delete destroy destroy*
CRUD REST HTML Create new get create post Read index
get show get Update edit get update put Delete destroy destroy*