module ActiveRecord::Marshalling::Methods

def marshal_load(state)

def marshal_load(state)
  attributes_from_database, new_record, associations = state
  attributes = self.class.attributes_builder.build_from_database(attributes_from_database)
  init_with_attributes(attributes, new_record)
  if associations
    associations.each do |name, target|
      association(name).target = target
    rescue ActiveRecord::AssociationNotFoundError
      # the association no longer exist, we can just skip it.
    end
  end
end