This is a smelly code and the alias method has been used at many places . Now I would want to call the actuals rails .destory method thereby deleting all assocaited dependents of Books - Is there a way I could ignore the alias method and call the .destory AR method ?
class Books < ActiveRecord::Base
def disable
self.is_active = false
save!
end
alias_method :destroy, :disable
end
That was an attempt at implementing paranoia mode, I guess. Smelly code, indeed. It overwrites
destroymethod and you can't call the original implementation anymore (easily). But you can save the original implementation!Now you can call
book.ar_destroyto invoke AR'sdestroyimplementation. Although, getting rid of the alias would be a better solution.