I would like to protect my model in production of of being deleted
It would be nice if rails provide this functionality by default ?
I don’t know if there is a functionality like this already but for me its something fundamental
If there is i couldn’t find nothing till now
Of Course there is the soft delete but this is a different concept
I dont know if my concept its valid or not or whats the gotchas but why protected_attributes and not protected_model?
class ProtectedModelError < ActiveRecordError #:nodoc:
super(“Cannot delete record because its protected”)
protected def delete(*args) raise ProtectedModelError.new end def destroy_all(*args) raise ProtectedModelError.new end def destroy(*args) raise ProtectedModelError.new end module ClassMethods def delete_all(*args) raise ProtectedModelError.new end end
class Query < ActiveRecord::Base
include ActiveRecord::ProtectedModel if Rails.env.production?