2

Setting:

A is a model

  • With attributes [name, email, actable_id, actable_type]

B and C are sub types of A (as an MTI relation)

Using this gem to simulate MTI

A.rb

class A < ActiveRecord::Base
  actable
  ...
end 

B.rb

class B < A
  acts_as :A
  ...
end 

C.rb

class C < A
  acts_as :A
  ...
end 

Problem: Queries on type B return on any table entry with parent A, including C.

c = C.create(name, email)

b = B.create(name, email)

B.first # Expected b, actual is c

B.count # Expected 1, actual 2
cmcdaniels
  • 145
  • 1
  • 3
  • 13

1 Answers1

1

The README doesn't tell you to inherit from A - it shows the "subclasses" still inheriting directly from ActiveRecord::Base

smathy
  • 26,283
  • 5
  • 48
  • 68