我有三个文件,这里是场未显示mongoid查询问题
class College
include Mongoid::Document
references_many :students,:stored_as => :array, :inverse_of => :colleges
end
class Student
include Mongoid::Document
embedded_in :college, :inverse_of => :students
embeds_one :mark
end
class Mark
include Mongoid::Document
embedded_in :student, :inverse_of => :mark
end
现在,当我在控制台
@college = College.find('4cb2a6457adf3500dd000089').students.where('mark.total' => '100').first.name
执行搜索这样的样品给了我零的有没有任何学生总分== 100
前提是大学存在但是相同的代码会在我的实际代码中产生错误
ERROR NoMethodError: undefined method `where' for Array:0x00000107441a30
任何想法为什么会发生这种情况?或者我做了一些错误的事情?
感谢
9个问题和0个接受如果您接受问题的答案,将来会收到更多的答案 – 2010-10-20 11:33:00