instance method
clone
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.3.18Available in: v2.2.3 v2.3.18
Signature
clone()
Returns a clone of the record that hasn’t been assigned an id yet and is treated as a new record. Note that this is a “shallow” clone: it copies the object’s attributes only, not its associations. The extent of a “deep” clone is application-specific and is therefore left to the application to implement according to its need.
Source
# File activerecord/lib/active_record/base.rb, line 2437
def clone
attrs = clone_attributes(:read_attribute_before_type_cast)
attrs.delete(self.class.primary_key)
record = self.class.new
record.send :instance_variable_set, '@attributes', attrs
record
end
Defined in activerecord/lib/active_record/base.rb line 2437
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base