質問編集履歴
1
community.rbを追加しました。確かに'published'とありますね...
title
CHANGED
File without changes
|
body
CHANGED
@@ -91,4 +91,19 @@
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
```
|
95
|
+
<community.rb>
|
96
|
+
```ここに言語を入力
|
97
|
+
class Community < ApplicationRecord
|
98
|
+
belongs_to :user
|
99
|
+
attachment :intro_image
|
100
|
+
has_many :follows, dependent: :destroy
|
101
|
+
|
102
|
+
with_options if: :published? do
|
103
|
+
validates :title, presence: true
|
104
|
+
validates :introduction, presence: true
|
105
|
+
# 複数valitatesをまとめたい場合はwith_optionsを使用(published?はメソッド名またはmodelのboolean項目)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
94
109
|
```
|