Created
February 12, 2021 02:52
-
-
Save nsiregar/9c6784a4fb0cc01485f0f45ddcb331db to your computer and use it in GitHub Desktop.
STI model inheritance Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePerson < ActiveRecord::Migration[6.0] | |
def change | |
create_table :people do |t| | |
t.string :type | |
t.string :name | |
t.integer :age | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person < ApplicationRecord | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student < Person | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Worker < Person | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment