comment.user associations with acts_as_commentable

I'm using acts_as_commentable and running in to a problem when trying to access objects associated with the comment.user.

For example: My app has groups, and a group belongs to a user. If I write group.user.comments, I'll see a hash for every comment that the group.user has made. However, if I try comment.user.groups, ActiveRecord tells me that the 'groups' method doesn't exist for user. The 'groups' method does exist when I write user.groups, however. So I'm betting this has something to do with the polymorphic associations in acts_as_commentable; but at the moment I don't understand how to make comments.user.groups work the way I want it to. Does anyone know what I'm missing?

Paul wrote:

Hi Neil,   I think I am having exactly this problem and I was wondering if you could tell me what you mean by "I finally fixed this by creating my own commentable associations." ?

In my app, I have events and users, both of which act_as_commentable. When I try to load comment.user.avatar (<-- an act_as_attachment image) I get the undefined method error (in my case 'avatar').

thanks

Paul

On Apr 6, 12:49 pm, Neil Cauldwell <rails-mailing-l...@andreas-s.net>

Hi Paul

It's been ages since I fixed this and I'm not even using polymorphic comments anymore. However, I believe the problem was fixed by simply creating my own polymorphic comments and dropping the plugin altogether. This is pretty easy to do. Just run the migration, create the comment model, set up the associations between the user and the comment, and that's it. The plugin (something to do with it being loaded as a plugin and a separate module, presumably) seemed to break the associations that belonged to the user.

Hope that helps