Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@lockethebiglobe

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

More than 1 year has passed since last update.

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はないですね

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

次いってみよ

0
Help us understand the problem. What is going on with this article?
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.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?