Firstly, thank you for creating this project 😄. We are using it for our non-ActiveRecord backed forms.
We have a base class that mixes in ShallowAttributes, but doesn't define attributes of its own. Any engineer can subclass this base class and have confidence that it will work out of the box in our forms and controllers.
Unfortunately we hit a bug where the subclass would raise TypeError: no implicit conversion of nil into Hash because it's trying to read default_values from a nil object which it expected to be a hash.
We have managed to work around it by defining MyExampleBaseClass.default_values to return an empty hash. While this is satisfactory it means the out of box experience with ShallowAttributes is not as smooth as it could be.
I hope you find this patch valuable and I'm open to any feedback you have.
Coverage increased (+0.02%) to 99.077% when pulling 9900e85a9cf1b738313eb603013344a39e2aff7d on fivegoodfriends:fix-inheritance-when-base-class-has-no-attributes into dd82ec67f65d778ae15ad62d80b9267ec0a52fba on davydovanton:master.
Hello,
Firstly, thank you for creating this project 😄. We are using it for our non-ActiveRecord backed forms.
We have a base class that mixes in
ShallowAttributes
, but doesn't define attributes of its own. Any engineer can subclass this base class and have confidence that it will work out of the box in our forms and controllers.Unfortunately we hit a bug where the subclass would raise
TypeError: no implicit conversion of nil into Hash
because it's trying to readdefault_values
from a nil object which it expected to be a hash.We have managed to work around it by defining
MyExampleBaseClass.default_values
to return an empty hash. While this is satisfactory it means the out of box experience withShallowAttributes
is not as smooth as it could be.I hope you find this patch valuable and I'm open to any feedback you have.
Cheers, Tate