Ruby on Rails where query with nesting relations

风流意气都作罢 提交于 2019-12-06 16:42:30
|improve this question

First, you're referencing reasons in a very haphazard way. User has_many reasons through projects, so why not go that route?

current_user.joins(:reasons).where(reasons.updated_at > ?", updated_at)

Secondly, and more specific to your error: your relation definition has_many :summaries, through: :projects, source: :reasons seems to be broken since projects don't have any summaries.

Consider adding a has_many :summaries, through: :reasons to your Project model, then use has_many :summaries, through: :projects in User.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!