This post describes my problem very well, but the answer to that post assumes that you use Single Table Inheritance (STI) for subclasses. In my case the subclasses of SomeProf
has their own tables and since the _type
column is storing the class name of the superclass, this is not working. In my equivalent to SomeDeepProf1
I have declared that self.table_name = 'some_other_table'
and I would not like to use STI since the subclasses of my equivalent to SomeProf
have very different attributes.
Any suggestion of how to solve this?
现在,我正在使用以下解决方法在SomeDeepProf1
类中解决此问题: before_create :set_poly_type_to_class_name ... def set_poly_type_to_class_name self.profile_type = self.profile.class.name end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.