Skip to content

Instantly share code, notes, and snippets.

@nsiregar
Created February 12, 2021 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsiregar/9c6784a4fb0cc01485f0f45ddcb331db to your computer and use it in GitHub Desktop.
Save nsiregar/9c6784a4fb0cc01485f0f45ddcb331db to your computer and use it in GitHub Desktop.
STI model inheritance Rails
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
class Person < ApplicationRecord
end
class Student < Person
end
class Worker < Person
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment