Skip to content

Instantly share code, notes, and snippets.

@roman-zaharenkov
Created October 8, 2013 14:11
Show Gist options
  • Select an option

  • Save roman-zaharenkov/6885322 to your computer and use it in GitHub Desktop.

Select an option

Save roman-zaharenkov/6885322 to your computer and use it in GitHub Desktop.
module TimestampsPatch
extend ActiveSupport::Concern
included do
remove_method :timestamps
end
# Monkey patch: make timestamps not-nullable by default.
def timestamps(*args)
options = args.extract_options!
options.reverse_merge!({ :null => false })
column(:created_at, :datetime, options)
column(:updated_at, :datetime, options)
end
end
module ModelToIntegerConverter
def to_i
self.id.to_i
end
end
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, TimestampsPatch)
ActiveRecord::ConnectionAdapters::Table.send(:include, TimestampsPatch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment