1
我有三個型號Mongoid嵌套協會不返回對象
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
這將返回我真不是消息數組,我認爲這應該。是我做錯了,或者我必須分兩部分來解決我的問題。