Activerecord has_many :through through multiple models

后端 未结 5 1451
忘掉有多难
忘掉有多难 2020-12-31 12:00

I\'m trying to access all comments from a given user with user.comments. The query is to go through two different models, which likely both return results. My r

5条回答
  •  死守一世寂寞
    2020-12-31 12:40

    I believe your associations would be confused, as user.comments wouldn't know whether it's going through Participant or Organiser, so the best option would be to declare two different joins (with different names):

    http://guides.rubyonrails.org/association_basics.html#self-joins

提交回复
热议问题