質問編集履歴
1
コードを見やすくしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
[開発環境]
|
2
2
|
cloud9, rails5.1.6
|
3
3
|
元々facebookでの認証機能を実装中に色々エラーが出たので、
|
4
|
-
ある記事を参考に一旦rails db:migrate:resetsを実行しrails serverを実行した所、次のエラーが出ました。
|
4
|
+
ある記事を参考に一旦`rails db:migrate:resets`を実行し`rails server`を実行した所、次のエラーが出ました。
|
5
5
|
↓
|
6
6
|
```
|
7
7
|
ActiveRecord::PendingMigrationError
|
8
8
|
Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development
|
9
9
|
```
|
10
|
-
エラー文の通りbin/rails db:migrate RAILS_ENV=developmentを実行すると下記のエラー文が出ました。
|
10
|
+
エラー文の通り`bin/rails db:migrate RAILS_ENV=development`を実行すると下記のエラー文が出ました。
|
11
11
|
↓
|
12
12
|
```
|
13
13
|
== 20200208142505 RenamePostIdColumnToComments: migrating =====================
|
@@ -24,8 +24,8 @@
|
|
24
24
|
その後にCommentモデルのmigrationファイルの内容自体を手動で変えたような気がします。
|
25
25
|
(大分前なので、あまり覚えていません) 現在↓
|
26
26
|

|
27
|
-
上記のエラー文を受け、Commentモデルの後に作った他のmigrationファイルは反映されているのか気になったので、rails db:migrate:statusを実行下みたら、3つ反映されていませんでした。
|
27
|
+
上記のエラー文を受け、Commentモデルの後に作った他のmigrationファイルは反映されているのか気になったので、`rails db:migrate:status`を実行下みたら、3つ反映されていませんでした。
|
28
|
-
[rails db:versionで確認もしています。→Current version: 20200208135438 ]
|
28
|
+
[`rails db:version`で確認もしています。→Current version: 20200208135438 ]
|
29
29
|
```
|
30
30
|
Status Migration ID Migration Name
|
31
31
|
--------------------------------------------------
|
@@ -39,10 +39,10 @@
|
|
39
39
|
down 20200210064310 Create favorites
|
40
40
|
down 20200218065956 Add omniauth to users
|
41
41
|
```
|
42
|
-
この後に,rails consoleでComment.columns.map(&:name)を実行し、Commentテーブルのカラムを確認。
|
42
|
+
この後に,`rails console`で`Comment.columns.map(&:name)`を実行し、Commentテーブルのカラムを確認。
|
43
|
-
→["id", "content", "user_id", "micropost_id", "created_at", "updated_at"]
|
43
|
+
→`["id", "content", "user_id", "micropost_id", "created_at", "updated_at"]`
|
44
44
|
micropost_idになっていました。
|
45
|
-
Favorite.columns.map(&:name)を実行すると、Favoriteテーブルは見つからないという結果。
|
45
|
+
`Favorite.columns.map(&:name)`を実行すると、Favoriteテーブルは見つからないという結果。
|
46
46
|
→ActiveRecord::StatementInvalid: Could not find table 'favorites'
|
47
47
|
ですが、schema.rbを見ると、Favoriteテーブルは存在します。
|
48
48
|
```
|