Bryan, Since dm-is-remixable creates the necessary comment tables behind the scenes, the comments for *any given user* (user.comments) are spread out over a few tables! The same would be true for the User.authored_comments method you mentioned, although that implies a class method which imo should list *all not anonymous comments* i.e. all records in all comment tables that are associated with *any* user_id. Now these can either be *all* comments if you don't allow anonymous commenting, or only the ones authored by a known user.
You could have a look at http://github.com/snusnu/dm-is-commentable and see if it fits your needs. It does its job using dm-is-remixable and you have the possibility for anonymous and/or not anonymous commenting. However, it doesn't support the kind of query you wish to perform out of the box, but actually this should be rather easy to add. I'm thinking along the lines of registering each generated comment model within some module accessor method, when it gets remixed. This could be done inside the is_commentable method within my plugin. Whenever it gets called, it needs to store the remixed model in a module accessor on Comment somehow like so ... module Comment def self.register_commenting_model(model) (@commenting_models ||= []) << model end def self.commenting_models @commenting_tables end end Now Comment.commenting_models could be used to generate the results you want easily? If dm-is-commentable otherwise pleases your needs, you could fork it and add the new functionality yourself if it's really urgent for you. I won't have time to do it today, but I could look at it tomorrow, it sounds like something I could need sometime in the future as well. cheers snusnu On Thu, Jan 29, 2009 at 00:01, Bryan <[email protected]> wrote: > > I'm trying to get my head around how to get the reverse association > that remixable provides. I don't really know how to explain it so > here's a gist: > > http://gist.github.com/54241 > > Basically, I need to be able to do User.authored_comments to be able > to get all the comments authored by a user regardless of the model the > comment belongs to. > > Any help would be greatly appreciated. > > -Bryan > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
