You mix a couple of things.
1 - destroy doesn’t really exist in the class where you turn on your module before you turn on your module.
The long story is that the destroy method is probably generated and included in your ORM gem.
You can use ruby 2+ prepend to make sure your module appears after all the methods.
2 - You can use the vanilla module or ActiveSupport::Concern
while you get what you want and know what you are doing.
The ActiveSupport::Concern
point is primarily for managing module hierarchies. If you have one level, I see no reason to use it. I think mixing prepend
with ActiveSupport::Concern
not a good idea.
(And after all, ActiveSupport::Concern
is just vanilla modules at the end.)
3 - The recommended way to override a method while keeping the old one is to use alias_method_chain .
You will have the destroy_without_archive method available, which will be the old way to execute it (before you flip it).
source share