質問編集履歴
1
post.rbを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,6 +58,32 @@
|
|
58
58
|
|
59
59
|
```
|
60
60
|
|
61
|
+
post.rb
|
62
|
+
|
63
|
+
```rails5
|
64
|
+
|
65
|
+
class Post < ApplicationRecord
|
66
|
+
|
67
|
+
validates :content, {presence: true, length: {maximum: 140}}
|
68
|
+
|
69
|
+
validates :user_id, {presence: true}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
def user
|
74
|
+
|
75
|
+
return User.find_by(id: self.user_id)
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
61
87
|
|
62
88
|
|
63
89
|
|