Sha256: 435cfc99bc836f76efa14dad11889035fe47795b7f907df1f284580ef8f79f11
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true require 'active_record' ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' class Person < ActiveRecord::Base serialize :custom_attributes connection.create_table table_name, force: true do |t| t.string :first_name t.string :last_name t.integer :age t.text :custom_attributes end def year_born Time.local(2014, 1, 1).year - age end end class Parent < ActiveRecord::Base has_many :children connection.create_table table_name, force: true do |t| t.string :name t.text :custom_attributes end end class Child < ActiveRecord::Base belongs_to :parent connection.create_table table_name, force: true do |t| t.integer :parent_id t.string :name end end class Supplier < ActiveRecord::Base has_one :account has_one :account_history, through: :account accepts_nested_attributes_for :account, :account_history serialize :custom_attributes connection.create_table table_name, force: true do |t| t.integer :account_id t.integer :account_history_id t.string :name t.text :custom_attributes end end class Account < ActiveRecord::Base belongs_to :supplier has_one :account_history accepts_nested_attributes_for :account_history connection.create_table table_name, force: true do |t| t.integer :supplier_id t.string :name t.integer :tax_identification_number end end class AccountHistory < ActiveRecord::Base belongs_to :account connection.create_table table_name, force: true do |t| t.integer :account_id t.integer :credit_rating end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tablesmith-0.6.2 | spec/fixtures.rb |
tablesmith-0.6.0 | spec/fixtures.rb |
tablesmith-0.5.0 | spec/fixtures.rb |