Download presentation
Presentation is loading. Please wait.
Published byAshley Griffin Modified over 8 years ago
1
MVC Controllers https://flic.kr/p/4MRZPn
2
TestsMigrations Ye Olde Internet Model DB Server Router View Browser Today’s focus Controller
3
5 Basic Controller Patterns Create – new/create: Enter a new record Read – index: List all records – show: Display a particular record Update – edit/update: Modify an existing record Delete – destroy: Remove a record
4
5 Basic Controller Patterns Create – new/create: Enter a new record Read – index: List all records – show: Display a particular record Update – edit/update: Modify an existing record Delete – destroy: Remove a record
5
index Page
6
Ye Olde Internet Model DB Server Router View Browser How to implement index? Controller
7
Ye Olde Internet Model DB Server Router View Browser How to implement index? Controller 1.Route “index” URL pattern 2.Controller uses Model to retrieve records 3.Controller uses View to generate HTML (passes records to View) 1 2 3 Demo Time!
8
5 Basic Controller Patterns Create – new/create: Enter a new record Read – index: List all records – show: Display a particular record Update – edit/update: Modify an existing record Delete – destroy: Remove a record ✔
9
new Form
10
Ye Olde Internet Model DB Server Router View Browser How many HTTP requests does it take to create a record? Controller
11
Ye Olde Internet Model DB Server Router View Browser How many HTTP requests does it take to create a record? Controller Two: One to request a form (GET) One to perform the add (POST)
12
Ye Olde Internet Model DB Server Router View Browser How to implement get form? Controller
13
Ye Olde Internet Model DB Server Router View Browser How to implement get form? Controller 1.Route URL pattern 2.Controller uses View to generate HTML (passes View records) 1 2
14
Ye Olde Internet Model DB Server Router View Browser How to implement post new record? Controller
15
Ye Olde Internet Model DB Server Router View Browser How to implement post new record? Controller 1.Route URL pattern 2.Controller uses Model to add rec 3.Controller sends HTTP redirect 1 2 3 Demo Time!
16
5 Basic Controller Patterns Create – new/create: Enter a new record Read – index: List all records – show: Display a particular record Update – edit/update: Modify an existing record Delete – destroy: Remove a record ✔ ✔ Demo Time! Like index Like create Needs explaining…
17
Appendix
18
TestsMigrations Ye Olde Internet Model DB Server Router View Browser Controller
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.