lib/acts_as_changesetable/acts/changeable_history.rb
# Conditionally creates a new change history item based on the changeable given
# Use force to ignore the dirty tracking of Rails and just force a new history.
# (Useful since new objects are not considered dirty)
Conditionally creates a new change history item based on the changeable given
Use force to ignore the dirty tracking of Rails and just force a new history.
(Useful since new objects are not considered dirty)
Conditionally creates a new change history item based on the changeable given Use force to ignore the dirty tracking of Rails and just force a new history . ( Useful since new objects are not considered dirty )
def new_from_changeable(changeable, force = false)
        my_fields = changeable.changeable_fields.map{|m| m.to_s}
        if(force || (my_fields & changeable.changed).size > 0 || changeable.new_record? || changeable.frozen?)
          new_change = self.new
          new_change.send("#{self.changeable_fk}=", changeable.id)
          for field in changeable.changeable_fields
            new_change.send("#{field}=", changeable.send(field))
          end
          unless self.changesetable_options.no_copy_timestamps?
            new_change.updated_at = changeable.updated_at if(changeable.respond_to?(:updated_at) && new_change.respond_to?(:updated_at))
            new_change.created_at = changeable.created_at if(changeable.respond_to?(:created_at) && new_change.respond_to?(:created_at))
          end
          unless self.changesetable_options.no_copy_deleted?
            new_change.deleted_at = changeable.deleted_at if(changeable.respond_to?(:deleted_at) && new_change.respond_to?(:deleted_at))
          end
          new_change.changeset = self.changeset_class.active_changeset
          new_change.save
          new_change
        else
          return false
        end
      end
def new_from_changeable ( changeable , force = false ) my_fields = changeable . changeable_fields . map { | m | m . to_s } if ( force || ( my_fields & changeable . changed ) . size > 0 || changeable . new_record? || changeable . frozen? ) new_change = self . new new_change . send ( "#{self.changeable_fk}=" , changeable . id ) for field in changeable . changeable_fields new_change . send ( "#{field}=" , changeable . send ( field ) ) end unless self . changesetable_options . no_copy_timestamps? new_change . updated_at = changeable . updated_at if ( changeable . respond_to? ( :updated_at ) && new_change . respond_to? ( :updated_at ) ) new_change . created_at = changeable . created_at if ( changeable . respond_to? ( :created_at ) && new_change . respond_to? ( :created_at ) ) end unless self . changesetable_options . no_copy_deleted? new_change . deleted_at = changeable . deleted_at if ( changeable . respond_to? ( :deleted_at ) && new_change . respond_to? ( :deleted_at ) ) end new_change . changeset = self . changeset_class . active_changeset new_change . save new_change else return false end end
Conditionally creates a new change history item based on the changeable given
Use force to ignore the dirty tracking of Rails and just force a new history.
Conditionally creates a new change history item based on the changeable given Use force to ignore the dirty tracking of Rails and just force a new history .
# Create field names from symbols # Find the intersection of tracked fields and changed fields for item.
changeable
<not_specific>
force
<not_specific>