次のスクリプトで、テーブル定義とActiveRecordクラスを用意します。
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Schema.define do create_table :employees do |t| t.string :name t.integer :age t.boolean :admin t.date :hired_at t.decimal :salary t.float :loyalty end end class Employee < ActiveRecord::Base; end
Employee.columns_hash.map{[_1,_2.type]}.to_h => {"id"=>:integer, "name"=>:string, "age"=>:integer, "admin"=>:boolean, "hired_at"=>:date, "salary"=>:decimal, "loyalty"=>:float}