If I use STI, I'll have several nil columns on my DB and I don't know if I can use Polymorphic Associations in cases like that. Any tip or some references?
[!How the right way to modeling somethink like that?] [1][1]
Though I don't understand the language completely from the image. If I understand I think one Coordinator has many Junior employee and senior employee. And seems like both employee table has the same type of column. What I would do in this case is, I would just create one employee table and keep a enum column of role. The model would look something like below-
class Coordinator
has_many: :employees
end
class Employee
belongs_to: :coordinator
enum role: { junior: 0, senior: 1 }
end
If you haven't used enum in Rails yet, it's really handy. Take a look
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.