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
1
650
Putting CRUD to REST: An Introduction to RESTful Routing by Dan Berger
Viking Education
July 17, 2015
Tweet
Share
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
420
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.1k
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
共有と分離 - Compose Multiplatform "本番導入" の設計指針
error96num
1
360
Snowflake Intelligenceにはこうやって立ち向かう!クラシルが考えるAI Readyなデータ基盤と活用のためのDataOps
gappy50
0
110
人工衛星のファームウェアをRustで書く理由
koba789
13
7.2k
Agile PBL at New Grads Trainings
kawaguti
PRO
1
400
[ JAWS-UG 東京 CommunityBuilders Night #2 ]SlackとAmazon Q Developerで 運用効率化を模索する
sh_fk2
3
380
Flutterでキャッチしないエラーはどこに行く
taiju59
0
230
Kiroと学ぶコンテキストエンジニアリング
oikon48
6
9.9k
EncryptedSharedPreferences が deprecated になっちゃった!どうしよう! / Oh no! EncryptedSharedPreferences has been deprecated! What should I do?
yanzm
0
220
ZOZOマッチのアーキテクチャと技術構成
zozotech
PRO
3
1.5k
サラリーマンの小遣いで作るtoCサービス - Cloudflare Workersでスケールする開発戦略
shinaps
2
410
COVESA VSSによる車両データモデルの標準化とAWS IoT FleetWiseの活用
osawa
1
270
Function Body Macros で、SwiftUI の View に Accessibility Identifier を自動付与する/Function Body Macros: Autogenerate accessibility identifiers for SwiftUI Views
miichan
2
180
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
431
66k
Side Projects
sachag
455
43k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
A Tale of Four Properties
chriscoyier
160
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.2k
The Power of CSS Pseudo Elements
geoffreycrofte
77
6k
Embracing the Ebb and Flow
colly
87
4.8k
A designer walks into a library…
pauljervisheath
207
24k
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*