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

Support Rails 7.1 #291

Closed y-yagi closed 1 year ago

y-yagi commented 1 year ago

This PR adds Rails 7.1 to the test matrix.

And, implementing composte_primary_key? method because Active Record uses this method since https://github.com/rails/rails/pull/47664 in some places.

Without this method, a spec fails with the following error.

 NoMethodError:
   undefined method `composite_primary_key?' for Country:Class
 # ./lib/active_hash/base.rb:227:in `method_missing'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/reflection.rb:863:in `association_primary_key'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/associations/belongs_to_association.rb:138:in `primary_key'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/associations/belongs_to_association.rb:127:in `replace_keys'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/associations/belongs_to_polymorphic_association.rb:26:in `replace_keys'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/associations/belongs_to_association.rb:98:in `replace'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/associations/singular_association.rb:19:in `writer'
 # lib/ruby/gems/3.2.0/gems/activerecord-7.1.1/lib/active_record/associations/builder/association.rb:112:in `subject='
 # ./spec/active_hash/base_spec.rb:1476:in `block (3 levels) in <top (required)>'

Ref: https://github.com/y-yagi/active_hash/actions/runs/6544200231/job/17770198096#step:4:15