Copying models

Scott,

AR overrides clone() to handle shallow copies. As for associations you'll have to handle these yourself. Here is a cut-and-paste from the rails source so you can see the implementation.

module ActiveRecord   class Base

      # 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.       def clone         attrs = self.attributes_before_type_cast         attrs.delete(self.class.primary_key)         self.class.new do |record|           record.send :instance_variable_set, '@attributes', attrs         end       end

  end end

Hope this helps.