1 / 28

MVC Controllers

https://flic.kr/p/4MRZPn. MVC Controllers. Browser. Migrations. Ye Olde Internet. DB. Tests. Today’s focus. Server. Router. Controller. Model. View. 5 Basic Controller Patterns. C reate new/create : Enter a new record R ead index : List all records

tbrock
Download Presentation

MVC Controllers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. https://flic.kr/p/4MRZPn MVC Controllers

  2. Browser Migrations Ye OldeInternet DB Tests Today’s focus Server Router Controller Model View

  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. new Form

  5. 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

  6. Browser Migrations Ye OldeInternet DB Tests Server Router Controller Model View

  7. 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

  8. index Page

  9. show Page

  10. 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

  11. edit Form

  12. 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

  13. destroy Link

  14. Appendix

  15. 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

  16. Browser How to implement index? Ye OldeInternet DB Server Router Controller Model View

  17. Browser How to implement index? Route “authors” URL pattern Controller uses Model to retrieve all records Controller uses View to generate HTML (passes records to View) Ye OldeInternet DB 1 2 3 Server Router Controller Model View

  18. Browser How to implement index? Ye OldeInternet DB Server Router Controller Model View

  19. Browser How to implement index? Route “author” URL pattern Controller uses Model to retrieve record with id in URL Controller uses View to generate HTML (passes record to View) Ye OldeInternet DB 1 2 3 Server Router Controller Model View

  20. 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 ✔ ✔

  21. Browser How many HTTP requests does it take to create a record? Ye OldeInternet DB Server Router Controller Model View

  22. Browser How many HTTP requests does it take to create a record? • Two: • One to request a form (GET) • One to perform the add (POST) Ye OldeInternet DB Server Router Controller Model View

  23. Browser How to implement get form? Ye OldeInternet DB Server Router Controller Model View

  24. Browser How to implement get form? Route URL pattern Controller uses View to generate HTML (passes View records) Ye OldeInternet DB 1 2 Server Router Controller Model View

  25. Browser How to implement post new record? Ye OldeInternet DB Server Router Controller Model View

  26. Browser How to implement post new record? Route URL pattern Controller uses Model to add rec Controller sends HTTP redirect Ye OldeInternet DB 1 2 3 Server Router Controller Model View

  27. 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 ✔ ✔ ✔ Like create Needs explaining…

  28. 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

More Related