質問編集履歴

1

item.rbを追記

2020/06/30 06:59

投稿

oozora127
oozora127

スコア1

test CHANGED
File without changes
test CHANGED
@@ -41,3 +41,49 @@
41
41
  エラーが発生している
42
42
 
43
43
  https://gyazo.com/ba122a8ccf0df93a231ec2074091ee21
44
+
45
+
46
+
47
+ #item.rb
48
+
49
+ ```ここに言語を入力
50
+
51
+ class Item < ApplicationRecord
52
+
53
+ has_many :item_images, dependent: :destroy
54
+
55
+ accepts_nested_attributes_for :item_images, allow_destroy: true
56
+
57
+
58
+
59
+ has_many :comments, dependent: :destroy
60
+
61
+ has_many :favorites, dependent: :destroy
62
+
63
+
64
+
65
+ belongs_to :category
66
+
67
+ belongs_to :brand, optional: true
68
+
69
+
70
+
71
+ belongs_to :seller_item, class_name:"User", optional: true
72
+
73
+ belongs_to :buyer_item, class_name:"User", optional: true
74
+
75
+
76
+
77
+ extend ActiveHash::Associations::ActiveRecordExtensions
78
+
79
+ belongs_to :prefecture, dependent: :destroy
80
+
81
+ belongs_to :brand, dependent: :destroy
82
+
83
+
84
+
85
+ end
86
+
87
+
88
+
89
+ ```