-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicitly define :_default_attribute_values
using class_attribute
in child class
#101
Conversation
…` in child class. Fix FooBarWidget#100
before
after
|
init_hash = !singleton_methods(false).include?(:_default_attribute_values) | ||
end | ||
|
||
if init_hash | ||
self._default_attribute_values = {} | ||
self._default_attribute_values_not_allowing_nil = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to dig into the history of the original code to better understand why we avoided initializing/resetting these class attributes previously and why it's ok now. I see the tests are green on older rails versions but I'm not sure the reason why this code was written like this.
@k-tsuchiya-jp did you figure out why your change is safe to do for rails 6 through 8?
Thanks for the possible fix for #100. See comment above. If you can explain it to me, I'd be more confident this change wouldn't break older versions of rails. Thank you! |
@k-tsuchiya-jp thanks, I missed this comment (#100 (comment)) before... after reviewing it and testing it locally with ruby 3.2 and 3.3 on the supported rails, your change is great. The original code dates back to 2012. Thanks for your contribution. |
@k-tsuchiya-jp released 4.1.1... thanks again! |
Detail
Fix #100
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]