hzamani / acts_as_relation

Multi table Inheritance for rails
http://hzamani.github.com/acts_as_relation/
MIT License
180 stars 58 forks source link

has_many :somethings << failing #47

Closed mikebaldry closed 10 years ago

mikebaldry commented 11 years ago

Given these models:

class User < ActiveRecord::Base
  has_many :message_sources
end

class MessageSource < ActiveRecord::Base
  acts_as_superclass

  belongs_to :user, polymorphic: true
end

class TwitterMessageSource < ActiveRecord::Base
  acts_as :message_source
end

When I

User.first.message_sources << TwitterMessageSource.new()

I get:

MessageSource(#70179625865060) expected, got TwitterMessageSource(#70179625930940)

mariopeixoto commented 10 years ago

The problem is that the class is 'acting as MessageSource' but does not inherit it. To make the << operator to work is necessary that the "subclass" returns true when the method twitter_message_source.is_a? MessageSource is invoked.

hzamani commented 10 years ago

fixed