Do not call it Set. So madness.
The deal is that the class definition is not executed because you are trying to override "Set", which is already defined in the global context.
class Set < ActiveRecord::Base
You can put your class in a module and then you will not get an error because you will define Set in the namespace.
module Custom class Set < ActiveRecord::Base end end
However, every time you want to use your Set class, you will have to refer to it as Custom :: Set. Many Rails magic will not work because they expect class names to be defined in a global context. You will neutralize plugins and gems left and right.
Itβs much easier to just give it a different name.
class CustomSet < ActiveRecord::Base
All magic works, and no monkeypatching binding is required.
Sarah mei
source share