-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path30_CRUD_and_scaffold_generators.txt
More file actions
56 lines (29 loc) · 1.47 KB
/
30_CRUD_and_scaffold_generators.txt
File metadata and controls
56 lines (29 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CRUD and scaffold generators - Text directions, references and code
--------------------------------------------------------------------------------------------
Query language to communicate with database: SQL (Structured Query Language)
CRUD actions:
C - Create
R - Read
U - Update
D - Delete
Scaffold generator command to create an article model (with two attributes), articles controller, views for articles and migration file to create articles table:
rails generate scaffold Article title:string description:text
Command to see routes presented in a viewer-friendly way:
rails routes --expanded
The line resources :articles in the config/routes.rb file provides the following routes:
- index of articles (GET request)
- new article (GET)
- create article (POST)
- edit article (GET)
- update article (PUT and PATCH)
- show article (GET)
- delete article (DELETE)
From UI perspective ->
- index lists all the articles in the articles table in the database of the app
- new article deals with the form to enter in new article details
- create handles the submission of the items in the new article form
- edit article deals with the form to enter edited information for an existing article
- update article deals with the submission of the edit article form
- show article displays an individual article based on selection
- delete article deletes an article from the articles table
In preparation for the next section, learn and practice SQL here: https://www.w3schools.com/sql/