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

質問編集履歴

2

a

2020/06/09 14:40

投稿

akaki
akaki

スコア15

title CHANGED
File without changes
body CHANGED
@@ -8,7 +8,6 @@
8
8
  [保存されている通知データのテーブル情報](https://i.gyazo.com/c85313df83f34a4e65077013a8573ed8.png)
9
9
 
10
10
  しかし、通知が表示されるビューに遷移すると、通知はないとされてしまいます。
11
- [保存されているはずのデータが表示されない(動画)](https://i.gyazo.com/80c10d4d66ee52ff251c51d9df8948fd.mp4)
12
11
 
13
12
  通知はテーブルに保存されており、削除ボタンを押すときちんと削除されるので正常に動いているとは思いますが、肝心の通知データをビューに表示する部分で躓いています。
14
13
 

1

データベースの追加

2020/06/09 14:40

投稿

akaki
akaki

スコア15

title CHANGED
File without changes
body CHANGED
@@ -150,7 +150,30 @@
150
150
  end
151
151
  end
152
152
  ```
153
+ ⬇︎データベース
154
+ ```
155
+ class CreateNotifications < ActiveRecord::Migration[5.2]
156
+ def change
157
+ create_table :notifications do |t|
158
+ t.integer :visiter_id, null: false
159
+ t.integer :visited_id, null: false
160
+ t.integer :cafeteria_id
161
+ t.integer :comment_id
162
+ t.string :action, default: '', null: false
163
+ t.boolean :checked, default: false, null: false
153
164
 
165
+ t.timestamps
166
+ end
167
+
168
+ add_index :notifications, :visiter_id
169
+ add_index :notifications, :visited_id
170
+ add_index :notifications, :cafeteria_id
171
+ add_index :notifications, :comment_id
172
+ end
173
+ end
174
+
175
+ ```
176
+
154
177
  ### 試したこと
155
178
 
156
179
  [参考Qiita1](https://qiita.com/yuto_1014/items/2db1dd4fcd7945b980f7)