質問編集履歴

2

migrationファイルを追加

2018/01/22 15:07

投稿

aaa10
aaa10

スコア13

test CHANGED
File without changes
test CHANGED
@@ -41,3 +41,31 @@
41
41
 
42
42
 
43
43
  なのでusers_controller.rbの@micropost = Micropost.find(params[:id])の.findを.whereに変更したのですが今度は「NoMethodError in Users#show」「undefined method `content' for #<Micropost::ActiveRecord_Relation:0x007fe3757f9558>」というエラーが出ました。
44
+
45
+
46
+
47
+ migrationファイルはこれです。
48
+
49
+ ```
50
+
51
+ class CreateMicroposts < ActiveRecord::Migration[5.1]
52
+
53
+ def change
54
+
55
+ create_table :microposts do |t|
56
+
57
+ t.text :content
58
+
59
+ t.integer :user_id
60
+
61
+
62
+
63
+ t.timestamps
64
+
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+
71
+ ```

1

.findを.whereに変更したが今度は「NoMethodError in Users#show」とエラーが出た

2018/01/22 15:07

投稿

aaa10
aaa10

スコア13

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  「ユーザーのshowページを編集し、ユーザーの最初のマイクロポストを表示してみましょう。同ファイル内の他のコードから文法を推測してみてください。うまく表示できたかどうか、/users/1 にアクセスして確認してみましょう。」
6
6
 
7
- このよ問題です。
7
+ という問題です。
8
8
 
9
9
 
10
10
 
@@ -36,4 +36,8 @@
36
36
 
37
37
  ```
38
38
 
39
- googleで調べたところこのようにするとうまくいくと書かれていたのですがうまくいきません。
39
+ googleで調べたところこのようにするとユーザーのshowページに表示されると書かれていたのですがうまくいきません。
40
+
41
+
42
+
43
+ なのでusers_controller.rbの@micropost = Micropost.find(params[:id])の.findを.whereに変更したのですが今度は「NoMethodError in Users#show」「undefined method `content' for #<Micropost::ActiveRecord_Relation:0x007fe3757f9558>」というエラーが出ました。