module ActiveRecord::Persistence::ClassMethods
def instantiate(attributes, column_types = {}, &block)
See ActiveRecord::Inheritance#discriminate_class_for_record to see
instances of the appropriate class for each record.
+instantiate+ instead of +new+, finder methods ensure they get new
by storing the record's subclass in a +type+ attribute. By calling
For example, +Post.all+ may return Comments, Messages, and Emails
the appropriate class. Accepts only keys as strings.
Given an attributes hash, +instantiate+ returns a new instance of
def instantiate(attributes, column_types = {}, &block) klass = discriminate_class_for_record(attributes) instantiate_instance_of(klass, attributes, column_types, &block) end