Sha256: fa9ffad75bad13b29c696217108b7066b24ba0d416137bca4b71b020f933b839
Contents?: true
Size: 682 Bytes
Versions: 12
Compression:
Stored size: 682 Bytes
Contents
$LOAD_PATH.unshift '../lib' require 'memory_record' require 'active_record' ActiveRecord::VERSION::STRING # => "5.1.4" ActiveRecord::Migration.verbose = false ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') ActiveRecord::Schema.define do create_table :users do |t| t.integer :gender_key end end class GenderInfo include MemoryRecord memory_record [ {key: :male, name: '♂'}, {key: :female, name: '♀'}, ] end class User < ActiveRecord::Base enum gender_key: GenderInfo.keys def gender_info GenderInfo[gender_key] end end user = User.create!(gender_key: :male) user.gender_info.name # => "♂"
Version data entries
12 entries across 12 versions & 1 rubygems