Really destroy acts_as_paranoid objects
I have a problem with with acts_as_paranoid objects. Now i want to really destroy the object but i cant find an easy way.
I dont like to use hard coded SQL for this problem.
Somebody knows a quick nice solution?
UPDATE
I came up with the following solution. I dont 开发者_如何学运维like this that much but it works....
# Use this function wisely
def really_destroy
ActiveRecord::Base.connection.execute("DELETE FROM user_widgets WHERE id = #{self.id}")
end
Add a bang to the destroy
method.
def really_destroy
self.destroy!
end
In case you want to destroy the already "soft deleted" i.e. whose "deleted_at" is already set, Just again destroy , Means two times destroy can destroy permanent deletes a record.
精彩评论