Closed julianrubisch closed 1 year ago
I ran into this error after I upgraded an app to Rails 7, which seems to have changed how association reflections are handled ?
Anyway, method_missing and respond_to_missing? were failing because of scopes being nil, which is always the case unless you specify at least one scope:
method_missing
respond_to_missing?
scopes
scope
https://github.com/active-hash/active_hash/blob/7a07bcc07abca9aca48b47186c23f85cf6ec7ced/lib/active_hash/base.rb#L375-L376
I've fixed this using safe navigation. An alternative would be to declare a default for the class_attribute here: https://github.com/active-hash/active_hash/blob/7a07bcc07abca9aca48b47186c23f85cf6ec7ced/lib/active_hash/base.rb#L24-L25
class_attribute
Let me know what you prefer!
Sorry. Not sure why this was not merged yet.
I ran into this error after I upgraded an app to Rails 7, which seems to have changed how association reflections are handled ?
Anyway,
method_missing
andrespond_to_missing?
were failing because ofscopes
being nil, which is always the case unless you specify at least onescope
:https://github.com/active-hash/active_hash/blob/7a07bcc07abca9aca48b47186c23f85cf6ec7ced/lib/active_hash/base.rb#L375-L376
I've fixed this using safe navigation. An alternative would be to declare a default for the
class_attribute
here: https://github.com/active-hash/active_hash/blob/7a07bcc07abca9aca48b47186c23f85cf6ec7ced/lib/active_hash/base.rb#L24-L25Let me know what you prefer!