Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Created December 14, 2011 02:15
Show Gist options
  • Save mgreenly/1474920 to your computer and use it in GitHub Desktop.
Save mgreenly/1474920 to your computer and use it in GitHub Desktop.
ignore column in active record
class User < ActiveRecord::Base
@@ignore_attr = ['lname']
def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
attrs = super(include_primary_key, include_readonly_attributes, attribute_names)
attrs.delete_if {|key,value| @@ignore_attr.include?(key.name) }
puts attrs.inspect
attrs
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment