active-hash / active_hash

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource
MIT License
1.19k stars 178 forks source link

Fix (Relation): add safe navigator operator after scopes for respond_to_missing? and method_missing methods #287

Closed Thornolf closed 11 months ago

Thornolf commented 1 year ago

Hello !

In our attempt to move our project to Ruby 3.2.2 we encountered an error : MethodError: undefined method 'key?' for nil:NilClass, the origin of the error was from relation.rb:173, our class did not had any scopes and so it was sending this error. We had multiples ideas to fix the issue but the simplest one was to just add a safe navigator operator. What do you think about that ? I'm available if you need me to do any other modifications.

Thank you !

flavorjones commented 1 year ago

@Thornolf Thank you for pointing out this issue and suggesting a fix!

Would you mind adding a test case that demonstrates the issue, to prevent regressions?

Thornolf commented 12 months ago

@Thornolf Thank you for pointing out this issue and suggesting a fix!

Would you mind adding a test case that demonstrates the issue, to prevent regressions?

Sure ! I will do it as soon as possible :) Thank you for the review !

kbrock commented 11 months ago

Thanks you @Thornolf

It looks like https://github.com/active-hash/active_hash/pull/278 was the same fix. I just merged that not knowing that this was also available.

I am closing this one as duplicate, but please let me know if you have other concerns

Thornolf commented 11 months ago

Oh indeed, sorry for the delay I was a bit busy at work 😅 I did not even saw the PR myself sorry for creating this duplicate ! Thank you for merging it 💪🏻