Skip to content

Instantly share code, notes, and snippets.

@ohammersmith
Created January 5, 2009 19:39
Show Gist options
  • Save ohammersmith/43504 to your computer and use it in GitHub Desktop.
Save ohammersmith/43504 to your computer and use it in GitHub Desktop.
def initialize(attributes = nil)
@attributes = attributes_from_column_definition
@attributes_cache = {}
@new_record = true
ensure_proper_type
self.attributes = attributes unless attributes.nil?
self.class.send(:scope, :create).each { |att,value| self.send("#{att}=", value) } if self.class.send(:scoped?, :create)
result = yield self if block_given?
callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment