lib/acts_as_versioned.rb
# Saves a version of the model in the versioned table.  This is called in the after_save callback by default
Saves a version of the model in the versioned table.  This is called in the after_save callback by default
Saves a version of the model in the versioned table . This is called in the after_save callback by default
def save_version
          if @saving_version
            @saving_version = nil
            rev = self.class.versioned_class.new
            clone_versioned_model(self, rev)
            rev.version = send(self.class.version_column)
            rev.send("#{self.class.versioned_foreign_key}=", id)
            if rev.version > 1
              rev.updated_attributes = changed
              rev.updated_attributes.delete_if { |attr| self.non_versioned_columns.include?(attr) }
            else
              rev.updated_attributes = []
            end
            rev.save
          end
        end
def save_version if @saving_version @saving_version = nil rev = self . class . versioned_class . new clone_versioned_model ( self , rev ) rev . version = send ( self . class . version_column ) rev . send ( "#{self.class.versioned_foreign_key}=" , id ) if rev . version > 1 rev . updated_attributes = changed rev . updated_attributes . delete_if { | attr | self . non_versioned_columns . include? ( attr ) } else rev . updated_attributes = [ ] end rev . save end end
Saves a version of the model in the versioned table.
Saves a version of the model in the versioned table .
# save off which attributes were changed for this version, unless first version # remove any non-versioned columns