質問編集履歴
2
文字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
よろしくお願いいたします。
|
65
65
|
|
66
66
|
### ※追記(2020/03/27)
|
67
|
-
post
|
67
|
+
models/post.rb
|
68
68
|
```
|
69
69
|
class Post < ApplicationRecord
|
70
70
|
belongs_to :user
|
@@ -76,7 +76,7 @@
|
|
76
76
|
validates :opinion, presence: true
|
77
77
|
end
|
78
78
|
```
|
79
|
-
genre
|
79
|
+
models/genre.rb
|
80
80
|
```
|
81
81
|
class Genre < ApplicationRecord
|
82
82
|
has_many :genre_posts
|
1
指摘いただいたモデルの追記いたしました
title
CHANGED
File without changes
|
body
CHANGED
@@ -61,4 +61,27 @@
|
|
61
61
|
```
|
62
62
|
|
63
63
|
情報不足であれば指摘していただけるとありがたいです。
|
64
|
-
よろしくお願いいたします。
|
64
|
+
よろしくお願いいたします。
|
65
|
+
|
66
|
+
### ※追記(2020/03/27)
|
67
|
+
postモデル
|
68
|
+
```
|
69
|
+
class Post < ApplicationRecord
|
70
|
+
belongs_to :user
|
71
|
+
belongs_to :category
|
72
|
+
has_many :genre_posts
|
73
|
+
has_many :genres, through: :genre_posts
|
74
|
+
|
75
|
+
validates :title, presence: true
|
76
|
+
validates :opinion, presence: true
|
77
|
+
end
|
78
|
+
```
|
79
|
+
genreモデル
|
80
|
+
```
|
81
|
+
class Genre < ApplicationRecord
|
82
|
+
has_many :genre_posts
|
83
|
+
has_many :posts, through: :genre_posts
|
84
|
+
|
85
|
+
validates :name, presence: true
|
86
|
+
end
|
87
|
+
```
|