You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> ⚠️ **Important**: If you rename the migration file, you **must update the class name** inside the file to match, or Rails will raise a `NameError` about a missing class.
113
+
114
+
#### Using the `change` Method
115
+
116
+
Rails migrations often use the `change` method instead of `up` and `down` for simpler reversible actions.
117
+
Rails can **automatically reverse** the following methods:
118
+
119
+
-`add_column`
120
+
-`add_index`
121
+
-`add_timestamps`
122
+
-`create_table`
123
+
-`remove_timestamps`
124
+
-`rename_column`
125
+
-`rename_index`
126
+
-`rename_table`
127
+
128
+
> For more complex migrations, use explicit `up` and `down` methods.
129
+
130
+
### Model
131
+
132
+
Student model represents a single student, so it's singular. The students table holds all of the students, so it's plural.
133
+
134
+
Create a model
135
+
136
+
```shell
137
+
rails g model Student first_name:string last_name:string gender:string
138
+
```
139
+
90
140
## Code Quality Tools
91
141
92
142
### RuboCop
@@ -136,68 +186,6 @@ bundle exec rspec
136
186
annotate
137
187
```
138
188
139
-
# Initialization
140
-
141
-
For macOS
142
-
143
-
Postgresql setup
144
-
```
145
-
brew install postgresql
146
-
brew services start postgresql
147
-
```
148
-
149
-
Create an app with postgresql
150
-
151
-
```
152
-
rails new app --database=postgresql
153
-
bin/rails db:migrate
154
-
```
155
-
156
-
```
157
-
rails g controller admin index
158
-
```
159
-
160
-
161
-
162
-
# Database
163
-
164
-
Student model represents a single student, so it's singular. The students table holds all of the students, so it's plural.
165
-
166
-
Create a model
167
-
168
-
```
169
-
rails g model Student first_name:string last_name:string gender:string
0 commit comments