質問するログイン新規登録

質問編集履歴

1

モデル追加

2020/06/08 08:11

投稿

pecchan
pecchan

スコア592

title CHANGED
File without changes
body CHANGED
@@ -61,4 +61,26 @@
61
61
  end
62
62
  end
63
63
 
64
+ ```
65
+
66
+ 各モデルは以下のようにしてます。
67
+ ```ruby
68
+ class Item < ApplicationRecord
69
+ belongs_to :sub_category
70
+ belongs_to :category
71
+ belongs_to :prefecture
72
+ end
73
+
74
+ class Category < ApplicationRecord
75
+ has_many :sub_categories
76
+ end
77
+
78
+ class SubCategory < ApplicationRecord
79
+ belongs_to :category
80
+ end
81
+
82
+ class Prefecture < ApplicationRecord
83
+ end
84
+
85
+
64
86
  ```