質問編集履歴

1

補足の追記

2017/03/14 06:00

投稿

lapi
lapi

スコア58

test CHANGED
File without changes
test CHANGED
@@ -97,3 +97,67 @@
97
97
 
98
98
 
99
99
  説明が分かりづらい点もあるかとは思いますが、ご教授のほどよろしくお願いします。
100
+
101
+
102
+
103
+
104
+
105
+ ###補足
106
+
107
+ ``notificationsテーブル``
108
+
109
+ ```
110
+
111
+ create_table "notifications", force: :cascade do |t|
112
+
113
+ t.boolean "read", default: false
114
+
115
+ t.integer "user_id"
116
+
117
+ t.integer "comment_id"
118
+
119
+ t.datetime "created_at", null: false
120
+
121
+ t.datetime "updated_at", null: false
122
+
123
+ t.integer "commenttl_id"
124
+
125
+ end
126
+
127
+
128
+
129
+ add_index "notifications", ["comment_id"], name: "index_notifications_on_comment_id", using: :btree
130
+
131
+ add_index "notifications", ["commenttl_id"], name: "index_notifications_on_commenttl_id", using: :btree
132
+
133
+ add_index "notifications", ["user_id"], name: "index_notifications_on_user_id", using: :btree
134
+
135
+ ```
136
+
137
+
138
+
139
+ 下記のようにトピック、あるいはタイムラインのみを取得すると、どちらかのデータは正常に表示はできます。
140
+
141
+ 下記の場合はトピックに関するお知らせのみ表示されます。
142
+
143
+
144
+
145
+ ``notifications/index.html.erb``
146
+
147
+ ```html
148
+
149
+ <h2>お知らせ</h2>
150
+
151
+ <% @notifications.each do |notification| %>
152
+
153
+ <p>
154
+
155
+ <%= notification.comment.user.try(:name) %>さんが
156
+
157
+ あなたの投稿(<%= link_to "#{notification.comment.topic.title}", topic_path(notification.comment.topic, notification_id: notification.id) %>)にコメントしました。
158
+
159
+ </p>
160
+
161
+ <% end %>
162
+
163
+ ```