質問編集履歴
1
加筆
test
CHANGED
File without changes
|
test
CHANGED
@@ -191,6 +191,30 @@
|
|
191
191
|
</div>
|
192
192
|
<% end %>
|
193
193
|
```
|
194
|
+
```models/item.rb
|
195
|
+
class Item < ApplicationRecord
|
196
|
+
extend ActiveHash::Associations::ActiveRecordExtensions
|
197
|
+
belongs_to :user
|
198
|
+
has_one :purchase_log
|
199
|
+
has_many_attached :images
|
200
|
+
belongs_to :category
|
201
|
+
belongs_to :condition
|
202
|
+
belongs_to :shipping_day
|
203
|
+
belongs_to :shipping_fee
|
204
|
+
belongs_to :shipping_from
|
205
|
+
|
206
|
+
validates :name, presence: true
|
207
|
+
validates :description, presence: true
|
208
|
+
validates :category_id, numericality: { other_than: 1, message: "can't be blank" }
|
209
|
+
validates :condition_id, numericality: { other_than: 1, message: "can't be blank" }
|
210
|
+
validates :shipping_fee_id, numericality: { other_than: 1, message: "can't be blank" }
|
211
|
+
validates :shipping_from_id, numericality: { other_than: 1, message: "can't be blank" }
|
212
|
+
validates :shipping_day_id, numericality: { other_than: 1, message: "can't be blank" }
|
213
|
+
validates :price, numericality: { only_integer: true }
|
214
|
+
validates :images, length: { minimum: 1, maximum: 5, message: "は1枚以上5枚以下にしてください" }
|
215
|
+
end
|
216
|
+
|
217
|
+
```
|
194
218
|
|
195
219
|
他の箇所のコードが見たい場合是非お申し付けください!
|
196
220
|
当方一週間も解決できずだいぶメンタルにきてしまっています。
|