كائن متعدد الأشكال ينتمي إلى كائن شبه مستقر: Object_type غير صحيح
-
21-09-2019 - |
سؤال
يعتبر:
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'
تعديل: لقد شعرت بالارتباك لفترة من الوقت هناك. هذا ليس بالأمراض المنقولة جنسيا حقًا ، إنه مجرد ميراث ، مثل Employee
له طاولته الخاصة.
شكرًا!
المحلول
class Person < ActiveRecord::Base
self.abstract_class = true
end
لا تنتمي إلى StackOverflow