Skip to content

Instantly share code, notes, and snippets.

@jamesgolick
Forked from jbr/gist:420314
Created June 1, 2010 00:58
Show Gist options
  • Save jamesgolick/420436 to your computer and use it in GitHub Desktop.
Save jamesgolick/420436 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
freeze
rows > 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment