Hey guys, With the upcoming merger between Rails and Merb, I have decided to change my blog back to Rails from Merb, but still use DataMapper instead of ActiveRecord.
Everything has worked fairly smoothly, except one thing. I have a has many relationship between Post and Comments. When I try and do @post.comments, I get an error... "Cannot find the child_model Comment for Post" What's weird is in my controller, if I have something like... @comments = Comment.all(:post_slug => params[:id]) #params[:id] is the title slug, which is the primary key for post then @post.comments works. So I think it stems from something in my model definitions, which can be here... http://pastie.org/365781 Now, this code worked in Merb, and let me use the @post.comments. I think it has to do with the fact that my primary key for my Post is the slug, and the foreign key is called post_slug in the comments. Is there something I need to define when I say has n, :comments or belongs_to :post? something like child_key => "post_slug" or something? I think its so weird that in my contoller if I search for the @comments, and don't even reference it, its ok to say @post.comments. I would love to know why, just for my own knowledge. Any help would be most appreciated. Thanks! (BTW to give back to the community, I will write a blog about setting DM up with Rails and this fix included) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
