Associations

48 views
Skip to first unread message

Miron

unread,
May 10, 2011, 7:14:34 PM5/10/11
to DataMapper MongoDB Adapter
I tried a simple object model with associations:


class Student
include DataMapper::Mongo::Resource

property :id, ObjectId
property :name, String
property :age, Integer
end

class CourseStudent
include DataMapper::Mongo::Resource

property :id, ObjectId
belongs_to :course
belongs_to :student
end

class Course
include DataMapper::Mongo::Resource

has n, :course_students
has n, :students, :through => :course_student
property :id, ObjectId
property :name, String
end

But it seems to create an invalid mapping to mongo, with just one
field for CourseStudent rather than three. Do associations not work
with the current adapter?

solnic

unread,
May 13, 2011, 9:12:26 AM5/13/11
to DataMapper MongoDB Adapter
Hey!

Do you call DataMapper.finalize after all models are loaded?

Cheers

# solnic
Reply all
Reply to author
Forward
0 new messages