Skip to content

Instantly share code, notes, and snippets.

@esromneb
Forked from d3r1v3d/add_double_to_active_record.rb
Last active December 21, 2015 21:58
Show Gist options
  • Save esromneb/6371964 to your computer and use it in GitHub Desktop.
Save esromneb/6371964 to your computer and use it in GitHub Desktop.
module CustomColumnTypes
def double(*args)
if !args.last.is_a? Hash
args.push({})
end
args.last[:limit] = 53
float *args
end
end
module ActiveRecord
module ConnectionAdapters
class Table
include CustomColumnTypes
end
class TableDefinition
include CustomColumnTypes
end
end
end
class CreateVeryPreciseTimes < ActiveRecord::Migration
def up
create_table :very_precise_times do |t|
t.datetime :measured_at
t.double :measured_at_frac
end
end
def down
drop_table :very_precise_times
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment