tesoriere logo

datamapper - many-to-many parent child relationship

I started playing around with datamapper to see if I could model an many to many parent/child relationship (self-referential habtm?) for an upcoming project. The plan was to use sproutcore for the gui (once I figured it out!), and merb as a webservice that it interacts with.

Justin gave me a kickstart with datamapper, and I eventually came up with:


#Person.rb
class Person
  include DataMapper::Resource

  property :id, Integer, :serial => true

  has n, :relationships
  has n, :parents, :through => :relationships, :class_name => 'Person'
  has n, :children, :through => :relationships, :class_name => 'Person'

  # parent = Person.create()
  # child = Person.create()
  # relationship = Relationship.new(:parent => parent)
  # child.relationships << relationship
  # child.save

end

#Relationship.rb
class Relationship
  include DataMapper::Resource

  property :id, Integer, :serial => true
  belongs_to :person
  belongs_to :parent, :class_name => 'Person'
  belongs_to :child, :class_name => 'Person'
end

I’ll eventually write some spec’s for it.

tags:

COMMENTS

  • Amature Teens Galleries]couples home amateur[/url] - amature nude photo gallery said:

    yo. funny thread..

    top

  • Spanking Switching Stories]spankings kids[/url]: when spanking turns sexual said:

    hm… amazing post

    top

  • ?????????????????? ????? ???????? said:

    you have a fast hosting

    top

  • Forced Lifeguard Anal said:

    yeah… love this thread :) g

    top

  • wresia said:

    ? ????? ??????: ?????????!

    [url=http://bogachi.co.cc/kemerovo2/?p=11]???? ???? ? ????[/url] ??? ????????????? ? ???????????? [url=http://bogachi.co.cc/dzerzhinsk6/?p=37]????????????? ? ?????? ?????????[/url] ????? ?? ??????? ????? [url=http://bogachi.co.cc/ryazan5/?p=35]? ?????? ?????????? ? ???????????[/url] - ?????? ???????????? ? ??????? ?????? [url=http://bogachi.co.cc/rubcovsk1/?p=19]??????? ? ????????? ? ??????? ?????? ????????????[/url]: ????? ? ????????? ?? ??????????? [url=http://bogachi.co.cc/stavropol9/?p=22]??????? ?? ???? ???? ??????????[/url]: ? ?????????? ???? ???????????? ? ?????? [url=http://bogachi.co.cc/kolomna2/?p=33]??? ????????????? ? ????????[/url]: ?????????? ??? ????? [url=http://bogachi.co.cc/rostov-na-donu5/?p=43]??????? ??????? ?????? ????? ?????[/url] - ???????????? ? ????????? ? ??????-??-???? [url=http://bogachi.co.cc/vologda2/?p=29]????????????? ? ?????? ?? ?????[/url]: ??????? ???????????? ? ?????????? ???????? [url=http://bogachi.co.cc/nalchik4/?p=13]???????????? ? ???????? ? ?????? ?????????[/url] ??? ????????????? ? ?????? [url=http://bogachi.co.cc/nalchik4/?p=7]??????? ??? ???????????? ? ????????[/url] ??????? ???????????? ?? ????????? [url=http://bogachi.co.cc/berezniki9/?p=46]????????? ???? ?????????? ???????[/url]: ???????????? ? ??????? ?????? ? ?????????? [url=http://bogachi.co.cc/dzerzhinsk6/?p=40]???????????? ?? ????????? ?????????[/url] - ???????????? ? ???????? ??? ?????? [url=http://bogachi.co.cc/stavropol9/?p=40]???????????? ??? ?????? ? ??????[/url]: ???????? ??????? ?????? ????????????? [url=http://bogachi.co.cc/saransk4/?p=17]??? ????????????? ? ??????? ?????[/url]: ???????????? ? ???????? ? ???????? ???????? [url=http://bogachi.co.cc/saransk4/?p=34]??????? ?????????? ? ?????????[/url] - ???? ?????????? ? ???????????? [url=http://bogachi.co.cc/dzerzhinsk6/?p=16]???????? ??????? ????????????? ??? ????? ? ??????????[/url]: ????????? ???? ?????????? ??????? [url=http://bogachi.co.cc/novocheboksarsk8/?p=27]?????????????? ?????????? ? ???????????[/url] - ??????? ???????????? ? ???????? ?????????????? [url=http://bogachi.co.cc/samara3/?p=40]?????? ????????????? ? ???????????[/url] - ?????????? ? ?????? ? ??????????? [url=http://bogachi.co.cc/dzerzhinsk6/?p=34]?????????? ? ???????????[/url]: ???????????? ? ??????? ??????

    top

  • Indigo said:

    ? ?????: ?????????????..

    [url=http://gaygorod.co.cc/nazran3/?p=17]?????????? ??? ???????[/url] - ??? ?????? ?????????? [url=http://gaygorod.co.cc/novotroick1/?p=28]??? ?????????? ?????????? ? ???????????[/url]: ?????????? ??? ?????????? ?? ?????? [url=http://gaygorod.co.cc/bryansk2/?p=28]? ??????? ??? ??????????[/url] - ?????????? ??? ???? ?? ??????? ?????? [url=http://gaygorod.co.cc/vladivostok8/?p=22]??? ?????????? gaygay[/url]: ??????????? ????? ??? ?????????? [url=http://gaygorod.co.cc/vladivostok8/?p=29]??? ?????????? 16 ???[/url] - ??? ?????????? [url=http://gaygorod.co.cc/belgorod8/?p=7]?????????? ???? ?? ??? ??????[/url] - ????? ????? ??? ????????? [url=http://gaygorod.co.cc/noyabrsk7/?p=15]?????????? ?????[/url] ??? ?????????? date [url=http://gaygorod.co.cc/bryansk2/?p=22]?????????? ??? ????[/url] ??? ?????????? ????? ???? [url=http://gaygorod.co.cc/taganrog6/?p=16]?????? ? ?????????[/url] ????? ?????????? ??? ?????????? [url=http://gaygorod.co.cc/ivanovo8/?p=13]??? ??????? ??????????[/url] - ??? ?????? ??? ?????????? ? ??????? [url=http://gaygorod.co.cc/novocherkassk6/?p=14]????????????? ?????????? ??? ????[/url]: ???? ??? ???? [url=http://gaygorod.co.cc/syzran3/?p=5]??? ?????????? ?????[/url] ??? ???? ????????? ??????? [url=http://gaygorod.co.cc/ulyanovsk9/?p=6]???? ?????????? ????[/url] ?????????? ???? ?? ??? ?????? [url=http://gaygorod.co.cc/taganrog6/?p=11]???????? ??? ????[/url] ??? ?????????? ??? ????? [url=http://gaygorod.co.cc/jelektrostal3/?p=24]?????????? ????? ??? ????????? ????????????[/url] - ??? ?????????? ?? 40 [url=http://gaygorod.co.cc/novoshahtinsk2/?p=23]??? ?????????? gaygay[/url]: ??? ?????????? ? ??????????

    top

Leave a Reply

Your name and email are required, but your email will not be published. No HTML is allowed, please use Markdown.