def bootstrap(*records)
      uncached do
        primary_key = self.primary_key.to_sym
        
        # Remove records that are no longer being used
        records.flatten!
        ids = records.map {|record| record[primary_key]}.compact
        delete_all(ids.any? ? ["#{primary_key} NOT IN (?)", ids] : nil)
        
        # Find remaining existing records (to be updated)
        existing = all.inject({}) {|existing, record| existing[record.send(primary_key)] = record; existing}
        
        records.map! do |attributes|
          attributes.symbolize_keys!
          defaults = attributes.delete(:defaults)
          
          # Update with new attributes
          record =
            if record = existing[attributes[primary_key]]
              attributes.merge!(defaults.delete_if {|attribute, value| record.send("#{attribute}?")}) if defaults
              record.attributes = attributes
              record
            else
              attributes.merge!(defaults) if defaults
              new(attributes)
            end
          record.send("#{primary_key}=", attributes[primary_key])
          
          # Force failed saves to stop execution
          record.save!
          record
        end
        
        records
      end
    end
def bootstrap(*records)
      uncached do
        primary_key = self.primary_key.to_sym
        
        # Remove records that are no longer being used
        records.flatten!
        ids = records.map {|record| record[primary_key]}.compact
        delete_all(ids.any? ? ["#{primary_key} NOT IN (?)", ids] : nil)
        
        # Find remaining existing records (to be updated)
        existing = all.inject({}) {|existing, record| existing[record.send(primary_key)] = record; existing}
        
        records.map! do |attributes|
          attributes.symbolize_keys!
          defaults = attributes.delete(:defaults)
          
          # Update with new attributes
          record =
            if record = existing[attributes[primary_key]]
              attributes.merge!(defaults.delete_if {|attribute, value| record.send("#{attribute}?")}) if defaults
              record.attributes = attributes
              record
            else
              attributes.merge!(defaults) if defaults
              new(attributes)
            end
          record.send("#{primary_key}=", attributes[primary_key])
          
          # Force failed saves to stop execution
          record.save!
          record
        end
        
        records
      end
    end
Synchronizes the given records with existing ones.  This ensures that
 only the correct and most up-to-date records exist in the database.
 The sync process is as follows:
 * Any existing record that doesn't match is deleted
 * Existing records with matches are updated based on the given attributes for that record
 * Records that don't exist are created

 To create records that can be referenced elsewhere in the database, an
 id should always be specified.  Otherwise, records may change id each
 time they are bootstrapped.

 == Examples

   class Color < ActiveRecord::Base
     enumerate_by :name

     bootstrap(
       {:id => 1, :name => 'red'},
       {:id => 2, :name => 'blue'},
       {:id => 3, :name => 'green'}
     )
   end

 In the above model, the +colors+ table will be synchronized with the 3
 records passed into the +bootstrap+ helper.  Any existing records that
 do not match those 3 are deleted.  Otherwise, they are either created or
 updated with the attributes specified.

 == Defaults

 In addition to *always* synchronizing certain attributes, an additional
 +defaults+ option can be given to indicate that certain attributes
 should only be synchronized if they haven't been modified in the
 database.

 For example,

   class Color < ActiveRecord::Base
     enumerate_by :name

     bootstrap(
       {:id => 1, :name => 'red', :defaults => {:html => '#f00'}},
       {:id => 2, :name => 'blue', :defaults => {:html => '#0f0'}},
       {:id => 3, :name => 'green', :defaults => {:html => '#00f'}}
     )
   end

 In the above model, the +name+ attribute will always be updated on
 existing records in the database.  However, the +html+ attribute will
 only be synchronized if the attribute is nil in the database.
 Otherwise, any changes to that column remain there.