Closed minond closed 6 years ago
I can't believe I didn't think of this when we talked about it, but the problem is that the method being overridden is being redefined in the same class. Since it's not in a parent class, there is no parent method for super
to invoke, hence the NoMethod
error you are seeing. The workaround with alias
you've been using is actually the correct way to do this (assuming overriding an association is actually what you want to do).
An alternative would be simply not to define association at all.
Makes sense.
I have a model with a
has_many
association and a custom reader method of the same name. I would expect that callingsuper
would execute the original method, but it does not and I get a no such method exception instead. Removing everything from my model expect for the association and method, I am left with the following:This is what I get when I run my code:
Commenting out the
credential_options
method allows the original method to work as expected:Environment