Although my problem is specifically in Ruby on Rails, I also ask in general: I have a user table and you want some users to become students and others to be teachers. What is the best way to design a circuit in this case?
Edit: Although I initially accepted vonconrad's answer - it meets the original criteria - I need to open and configure the question again based on feedback from nhnb.
What if students and / or teachers need additional (unique) attributes?
, , . , , :
has_many :user, :polymorphic => true
users
user_attributes
id, user_type, username, etc.
id, user_id, attribute_name, value
, , , .
!
teacher. true, . , . .
teacher
(, , , , janitor (?)), UserGroup. user_group_id. . :
user_group_id
class User < ActiveRecord::Base belongs_to :user_group end class UserGroup < ActiveRecord::Base has_many :users end
.
Source: https://habr.com/ru/post/1782062/More articles:Magento customer account backup - phpDisable CONTROL + ALT + DELETE and Windows (win) Key in Windows 7 using the Win32 application - c ++How do TCP and UDP detect transmission errors? - network-protocolsRecommended server technology for gwt (newbie) - gwtHow to determine if two Pygame subsurfaces refer to the same area? - pythonC # to find all installed office updates - c #Where should the python bubble mapping mapping configuration file be located or named for a stand-alone script? - pythonWhy is MySQL multi-column index overpopulated? - mysqlRegex matches 2 html tags in 1 html file - htmlWhat is the relationship between installation, deployment, and release? - installAll Articles