質問編集履歴
1
モデルについて情報を追記いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -154,6 +154,49 @@
|
|
154
154
|
|1|5000円|1|1|1|
|
155
155
|
|2|Aローン|1|2|1|
|
156
156
|
|
157
|
+
モデル
|
158
|
+
```bank
|
159
|
+
class Bank < ApplicationRecord
|
160
|
+
has_many :bank_categories
|
161
|
+
has_many :categories, through: :bank_categories
|
162
|
+
has_many :contents
|
163
|
+
|
164
|
+
validates :name, presence: true
|
165
|
+
validates :name, uniqueness: true
|
166
|
+
end
|
167
|
+
```
|
168
|
+
|
169
|
+
```category
|
170
|
+
class Category < ApplicationRecord
|
171
|
+
has_many :bank_categories
|
172
|
+
has_many :banks, through: :bank_categories
|
173
|
+
has_many :contents
|
174
|
+
|
175
|
+
validates :subject, uniqueness: true
|
176
|
+
validates :number, uniqueness: true
|
177
|
+
end
|
178
|
+
```
|
179
|
+
|
180
|
+
```bankcategory
|
181
|
+
class BankCategory < ApplicationRecord
|
182
|
+
belongs_to :bank
|
183
|
+
belongs_to :category
|
184
|
+
end
|
185
|
+
```
|
186
|
+
|
187
|
+
```content
|
188
|
+
class Content < ApplicationRecord
|
189
|
+
belongs_to :bank
|
190
|
+
belongs_to :category
|
191
|
+
belongs_to :user
|
192
|
+
|
193
|
+
validates :detail, presence: true
|
194
|
+
validates :bank_id, presence: true
|
195
|
+
validates :category_id, presence: true
|
196
|
+
validates :user_id, presence: true
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
157
200
|
※上記テーブルのように情報が登録できればベストだと考えています。
|
158
201
|
|
159
202
|
### 試したこと
|