Elegant Way to Represent Polymorphic Relationship in Sequel Model? #2190
jvanderen1
started this conversation in
General
Replies: 1 comment 1 reply
-
You aren't dealing with multiple tables, so single_table_inheritance would be more appropriate than class_table_inheritance. You could then try: class HighSchoolStudent < Student
set_dataset :high_school_students_view
end If you aren't further subclassing |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We currently have a polymorphic relationship with one of our tables. Using views, we would like to be able to represent these views using separate model classes.
Example
Given the following example SQL:
Is it possible to have a single model reference these views correctly? I was thinking the
ClassTableInheritance
plugin would be a good choice:However, the SQL generated is quite ugly:
Is there anyway to modify a dataset to use a simplified query while returning the parent model class? Something like:
Beta Was this translation helpful? Give feedback.
All reactions