質問編集履歴
1
モデル追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,3 +125,47 @@
|
|
125
125
|
|
126
126
|
|
127
127
|
```
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
各モデルは以下のようにしてます。
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
|
135
|
+
class Item < ApplicationRecord
|
136
|
+
|
137
|
+
belongs_to :sub_category
|
138
|
+
|
139
|
+
belongs_to :category
|
140
|
+
|
141
|
+
belongs_to :prefecture
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
class Category < ApplicationRecord
|
148
|
+
|
149
|
+
has_many :sub_categories
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
class SubCategory < ApplicationRecord
|
156
|
+
|
157
|
+
belongs_to :category
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
class Prefecture < ApplicationRecord
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
```
|