2009-10-13 54 views
0

考慮:屬於準STI對象的多態對象:OBJECT_TYPE是不正確

class Person < ActiveRecord::Base 
    class << self 
    def setup 
     has_one :address, :as => :addressable 
    end 
    end 
end 

class Employee < Person 
    setup 
end 

class Address < ActiveRecord::Base 
    belongs_to :addressable, :polymorphic => true 
end 

# Shouldn't this be 'Employee'? Is it possible to override? 
Employee.create.address.create.addressable_type == 'Person' 

編輯:我糊塗了有一段時間。這不是真的STI,它只是繼承,因爲Employee有它自己的表格。

謝謝!

回答

1

Bingo

class Person < ActiveRecord::Base 
    self.abstract_class = true 
end 
相關問題