我試圖通過關聯的用戶名來查找包含在belongs_to關係中的記錄,但它不起作用。rails mongoid條件通過關聯查找
文章屬於用戶 用戶有很多文章
Article.where(user_id: someid)
工作正常,但我想使用的用戶名作爲存儲在用戶表引用。
Article.includes(:user).where(:username => "erebus")
Article.includes(:user).where("user.username" => "erebus")
我也有identity_map_enabled: true
Article.includes(:user).inclusions
返回的關係細節
不行的話,那我不理解?
如果我們從其他方式獲取數據並且當前集合中實際上沒有數組,但是其他數據一個? – Laurent 2016-05-31 14:46:20
哦,是的,我知道答案:你不能。 – Laurent 2016-05-31 14:51:07