Closed flavorjones closed 1 year ago
@flavorjones This looks great. A few thoughts:
(as with everywhere in rubyland. thanks for the contribution)
@kbrock Thanks for the review and for asking these questions.
This should "just work" for folks who have followed the README and are extending their AR classes with ActiveHash::Associations::ActiveRecordExtensions
(see this section in the README).
However, it looks like not all the tests were following that advice but were still passing with Rails 6 (see the change in this PR to spec/active_hash/base_spec.rb
), which seems suspicious and makes me believe there may be apps out there which are "working" but will break with Rails 7. Maybe I'm not fully understanding Active Hash and how it's supposed to be used? I could use some advice, honestly.
Looks like the ActiveRecordExtensions module was added in v0.9.6 (see 153c58ec) but wasn't added to this test (probably because it wasn't failing).
Thanks. I thought I remembered this module from a number of years ago.
Ok, I change my view from breaking change to bug fix.
@kbrock I just saw now that I still had a "wip" message in that last commit, urk, sorry, I should have fixed that. Candidly, I did not expect that code to pass on every Rails version and assumed I'd be coming back to clean something up. :shrug:
@flavorjones ugh. very sorry that I did not see that. ping me to get that through
Alternative implementation to #267 that doesn't monkeypatch ActiveRecord.
This implementation subclasses
ActiveRecord::Reflection::BelongsToReflection
and overrides thecompute_class
method to allow ActiveHash associations.I've also cherry-picked some relevant commits from #267.