see http://datamapper.org/docs/associations
Your problem is that "has 1, :feed_post" is not the same as "has n, :feed_posts", so the reflection isn't there for :through because DM assumes there is a relationship using ":feed_posts" in both models. I *think* doing this will make it work: class Post # ... has 1, :feed_post has 1, :feed, :through => :feed_post, :via => :feed end The :via key tells DM which relationship to use, though I'm only vaguely sure about how it works :) On Apr 26, 5:30 pm, Lumpidu <[email protected]> wrote: > Hi, > > I am learning DM, so please be forgiving .. > > Here's the model: > > class Feed > include DataMapper::Resource > > property :id, Serial > property :title, String, :key => true > property :url, Text > > has n, :feed_posts > has n, :posts, :through => feed_posts > > end > > class FeedPost > include DataMapper::Resource > > property :id, Serial > property :feed_title, String, :key=>true, :required => true > property :post_title, String, :key=>true, :required => true > > belongs_to :feed > belongs_to :post > end > > class Post > include DataMapper::Resource > > property :id, Serial > property :title, String, :key=> true > property :url, Text > property :timestamp, DateTime > property :content_raw, Text > > has 1, :feed_post > has 1, :feed, :through => feed_post > end > > Basically I want FeedPost to be the JOIN of the tables Feed and Post. > The combined titles of a feed and a post should be unique. > The above model produces: 'Cannot find the child_model FeedPost for > Feed in feed_posts (NameError)'. What am I doing wrong here ? -- 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.
