What's the best way to do "has n" and "belongs_to" associations
between two classes that are using two different databases?
My workaround hack, below, works for super-basic get, but it's so
inelegant, it seems the brighter minds here must have a better
solution.
Any advice?
#############################
DataMapper.setup(:default, 'postgres://localhost/blog')
DataMapper.setup(:people, 'postgres://localhost/people)
class Person
include DataMapper::Resource
def self.default_repository_name
:people
end
property :id, Serial
# has n, :comments
def comments
DataMapper.repository(:default) { Comment.all(:person_id => id) }
end
end
class Comment
include DataMapper::Resource
property :id, Serial
property :person_id, Integer, :required => true
# belongs_to :person
def person
DataMapper.repository(:people) { Person.get(person_id) }
end
end
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.