Skip to content

Instantly share code, notes, and snippets.

@jbr
Created May 31, 2010 21:51
Show Gist options
  • Save jbr/420314 to your computer and use it in GitHub Desktop.
Save jbr/420314 to your computer and use it in GitHub Desktop.
class ActiveRecord::Base
def destroy
unless new_record?
rows = connection.delete(
"DELETE FROM #{self.class.quoted_table_name} " +
"WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}",
"#{self.class.name} Destroy"
)
end
@destroyed = new_record? || rows > 0
freeze
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment