我有三个模型
class User
include Mongoid::Document
include Mongoid::Timestamps
has_many :conversation
end
class Conversation
include Mongoid::Document
include Mongoid::Timestamps
has_many :users
embeds_many :messages
end
class Messages
include Mongoid::Document
include Mongoid::Timestamps
embedded_in :conversation
end
我正在尝试获取一些用户消息
users.each do |user|
puts user.conversations.each {|conv| conv.messages}
end
这使我返回 true 而不是我认为应该的消息数组。是我做错了什么还是我必须将我的查询分成两部分。