Hello Everyone,

I was having some problems with many to many relationships.  To make
things simpler, I tried the examples from the datamapper website
(http://datamapper.org/doku.php?id=docs:associations), modifying the
code a little bit:

class Photo
  include DataMapper::Resource

  property :photo_id, Serial
  property :name, String

  has n, :taggings
  has n, :tags, :through => :taggings, :mutable => true
end

class Tag
  include DataMapper::Resource

  property :tag_id, Serial
  property :name, String

  has n, :taggings
  has n, :photos, :through => :taggings, :mutable => true

end

class Tagging
  include DataMapper::Resource

  property :tagging_id, Serial

  belongs_to :tag
  belongs_to :photo
end

When I try to do the following in irb:

p = Photo.new(:name => 'First Photo')
=> #<Photo photo_id=nil name="First Photo">
irb(main):002:0> p.save
=> true
irb(main):003:0> t = Tag.new(:name => 'cool')
=> #<Tag tag_id=nil name="cool">
irb(main):004:0> t.save
=> true
irb(main):005:0> p.tags << t
=> [#<Tag tag_id=1 name="cool">]
irb(main):006:0> p.save

After the last line, I get the following error:
undefined method `attach_parent' for
#<DataMapper::Associations::RelationshipChain:0xb73274d8>

Is this a bug or am I doing something wrong? I'm using MySQL and my
DataMapper version is 0.9.10.

Thanks for the help guys!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to