質問編集履歴
2
文章を少し変えました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -190,8 +190,6 @@
|
|
190
190
|
|
191
191
|
|
192
192
|
|
193
|
-
|
194
|
-
|
195
193
|
### 試したこと
|
196
194
|
|
197
195
|
|
1
like.rbとpost.rbを加えた。
test
CHANGED
File without changes
|
test
CHANGED
@@ -144,6 +144,52 @@
|
|
144
144
|
|
145
145
|
```
|
146
146
|
|
147
|
+
post.rb
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
class Post < ApplicationRecord
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
validates :content, {presence: true, length: {maximum: 140}}
|
156
|
+
|
157
|
+
validates :user_id, {presence: true}
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
def user
|
166
|
+
|
167
|
+
return User.find_by(id: self.user_id)
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
like.rb
|
178
|
+
|
179
|
+
```
|
180
|
+
|
181
|
+
class Like < ApplicationRecord
|
182
|
+
|
183
|
+
validates :user_id, {presence: true}
|
184
|
+
|
185
|
+
validates :post_id, {presence: true}
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
|
192
|
+
|
147
193
|
|
148
194
|
|
149
195
|
### 試したこと
|