Help us understand the problem. What is going on with this article?

Ruby on Rails チュートリアル(windows10環境)

Ruby on Rails チュートリアルをWindows10で動かしてみた h1

初投稿なので書き方は徐々に覚えていくつもりです

2・3・3 ユーザーはたくさんおおくのマイクロポストを持っているで
詰まっている


irb(main):040:0> first_usr = User.first
User Load (0.5ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT ? [["LIMIT", 1]]
=> #
irb(main):041:0> first_usr.microposts
Micropost Load (0.5ms) SELECT "microposts".* FROM "microposts" WHERE "microposts"."user_id" = ? LIMIT ? [["user_id", 1], ["LIMIT", 11]]
=> #, #]>
irb(main):042:0> micropost = first_user.microposts.first
Micropost Load (0.4ms) SELECT "microposts".* FROM "microposts" WHERE "microposts"."user_id" = ? ORDER BY "microposts"."id" ASC LIMIT ? [["user_id", 1], ["LIMIT", 1]]
=> #
irb(main):043:0> micropost.user
Traceback (most recent call last):
1: from (irb):43
NoMethodError (undefined method `user' for #Micropost:0x00000000063c1ad0)
Did you mean? user_id
irb(main):044:0> p micropost


Tracebackで
micropost のdid you mean? user_id
pメソッドで確認すると確かにmicropostの中にid やuser?id はあるがuserはないですね

チュートリアルをやっているのかやらされているのかわけがわからなくなってきた

次いってみよ

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした