I have a Three documents, here is a sample with fields not shown
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
Now when I perform the search like this in console
@college = College.find('4cb2a6457adf3500dd000089').students.where('mark.total' => '100').first.name
gives me nil as there is no any students with total marks == 100
provided that college exists but the same code raises error in my actual code as
ERROR NoMethodError: undefined method `where' for Array:0x00000107441a30
Any ideas why this is happening? OR have i done some thing wrong?
Thanks