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.2k stars 179 forks source link

Use double splat operator in belongs_to call to super #240

Closed gazayas closed 2 years ago

gazayas commented 2 years ago

I ran across this in a project I'm working on and found out other people were having the same problem: Issue #225.

super was calling the following method in ActiveRecord:

def belongs_to(name, scope = nil, **options)
  reflection = Builder::BelongsTo.build(self, name, scope, options)
  Reflection.add_reflection self, name, reflection
end

options was getting substituted into scope which was causing the bug. There might be a better fix for this (Using ruby2_keywords?) so I can look over the code just in case, but this fixes the issue for me.

cath-oneill commented 2 years ago

This was fixed in (f644831), but hasn't been included in a versioned release yet.