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

質問編集履歴

4

追記

2020/07/10 09:37

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -102,4 +102,7 @@
102
102
  class Post < ApplicationRecord
103
103
  belongs_to :user
104
104
  has_many :group_posts, dependent: :delete_all
105
- ```
105
+ ```
106
+ ###追記3
107
+ 現在のエラー
108
+ ![イメージ説明](268dcf882e93dd52ce411252a08df1e5.png)

3

追記

2020/07/10 09:37

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -83,4 +83,23 @@
83
83
  t.datetime "created_at", null: false
84
84
  t.datetime "updated_at", null: false
85
85
  end
86
+ create_table "posts", force: :cascade do |t|
87
+ t.text "content"
88
+ t.datetime "created_at", null: false
89
+ t.datetime "updated_at", null: false
90
+ t.integer "user_id"
91
+ t.string "image_name"
92
+ t.string "title"
93
+ end
94
+ ```
95
+ ```Model
96
+ class User < ApplicationRecord
97
+ has_many :posts, dependent: :delete_all
98
+ has_many :group_users
99
+ has_many :groups, through: :group_users
100
+ ```
101
+ ```Model
102
+ class Post < ApplicationRecord
103
+ belongs_to :user
104
+ has_many :group_posts, dependent: :delete_all
86
105
  ```

2

追記2

2020/07/10 07:46

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -56,4 +56,31 @@
56
56
  現在のエラーです。
57
57
  ![イメージ説明](bbd313887091e7f219df9d159e29f7cf.png)
58
58
  group_post_ids に変更した場合エラーは無くなりますが、if分の条件に該当せず閲覧出来ません。
59
- ![イメージ説明](9ed968e9fb4ccfff229ccd291f750792.png)
59
+ ![イメージ説明](9ed968e9fb4ccfff229ccd291f750792.png)
60
+ ###追記2
61
+ ```schema
62
+ create_table "group_posts", force: :cascade do |t|
63
+ t.integer "group_id"
64
+ t.integer "post_id"
65
+ t.datetime "created_at", null: false
66
+ t.datetime "updated_at", null: false
67
+ t.index ["group_id"], name: "index_group_posts_on_group_id"
68
+ t.index ["post_id"], name: "index_group_posts_on_post_id"
69
+ end
70
+
71
+ create_table "group_users", force: :cascade do |t|
72
+ t.integer "group_id"
73
+ t.integer "user_id"
74
+ t.datetime "created_at", null: false
75
+ t.datetime "updated_at", null: false
76
+ t.index ["group_id"], name: "index_group_users_on_group_id"
77
+ t.index ["user_id"], name: "index_group_users_on_user_id"
78
+ end
79
+
80
+ create_table "groups", force: :cascade do |t|
81
+ t.string "name"
82
+ t.text "content"
83
+ t.datetime "created_at", null: false
84
+ t.datetime "updated_at", null: false
85
+ end
86
+ ```

1

追記

2020/07/10 07:36

投稿

tomtom1
tomtom1

スコア168

title CHANGED
File without changes
body CHANGED
@@ -50,4 +50,10 @@
50
50
  あるいは、include?などを使う方法もあるのかな?とも考えています。
51
51
 
52
52
  現在、答えにたどり着けずにいます。
53
- お分かりの方、ぜひ宜しくお願いします。
53
+ お分かりの方、ぜひ宜しくお願いします。
54
+
55
+ ###追記
56
+ 現在のエラーです。
57
+ ![イメージ説明](bbd313887091e7f219df9d159e29f7cf.png)
58
+ group_post_ids に変更した場合エラーは無くなりますが、if分の条件に該当せず閲覧出来ません。
59
+ ![イメージ説明](9ed968e9fb4ccfff229ccd291f750792.png)