LoginSignup
1
0

More than 5 years have passed since last update.

<ActiveRecord::Associations::CollectionProxy エラーについて

Posted at

【<ActiveRecord::Associations::CollectionProxy エラーについて】

2.4.1 :019 > User.first.todays_events
  User Load (0.5ms)  SELECT  `users`.* FROM `users`   ORDER BY `users`.`id` ASC LIMIT 1
  TodaysEvent Load (0.5ms)  SELECT `todays_events`.* FROM `todays_events`  WHERE `todays_events`.`user_id` = 1
 => #ActiveRecord::Associations::CollectionProxy []> 
2.4.1 :020 

これは配列になっているため取得できないんですね。

http://stomo1986.hatenablog.com/entry/2013/12/16/091933
⇒確かに、複数のtodays_eventsがあるので、PCからしたらどれやねんって話でしょう。

どのtodays_eventsか確定させないと取得できない。
(例: Organization.find(4).users.find(5).login_id ←これは特定させて検索しているのでできる。

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