Skip to content

Instantly share code, notes, and snippets.

@oggy
Created December 7, 2012 22:56
Show Gist options
  • Save oggy/4237218 to your computer and use it in GitHub Desktop.
Save oggy/4237218 to your computer and use it in GitHub Desktop.
Make ActiveRecord ignore columns, so you can drop them without downtime.
ActiveRecord::Base.class_eval do
def self.ignore_columns(*names)
extend ColumnIgnorance
ignored_columns.merge names.map(&:to_s)
end
module ColumnIgnorance
def columns
return @columns if @columns
@columns = super.reject do |column|
ignored_columns.include?(column.name)
end
end
def ignored_columns
@ignored_columns ||= Set[]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment