LoginSignup
0
0

More than 3 years have passed since last update.

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

Posted at

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
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0