LTe/acts-as-messageable — Issue #21: messages method on model does not work with STI
Author: aagrawal2001
Created: 2011-12-15 03:23:12+00:00
State: open

If you have a model with inherited classes and you use acts-as-messageable on the base class, the messages method will always return 0 (because it's trying to make the type match the subclass). The received_messages and sent_messages methods work fine, however.

Example:
class User < ActiveRecord::Base
acts-as-messageable
end

class Buyer < User
end

class Seller < User
end

One way to fix this would be to rewrite messages = sent_messages + received_messages (requires 2 database queries).
Or, it could be turned into one union query.