-
Notifications
You must be signed in to change notification settings - Fork 190
Open
Description
The following association:
has_many :asset_types, through: :assignments, source: :assignable, source_type: "AssetType"raises the following exception as a result of #329:
/Users/jpcody/.local/share/mise/installs/ruby/3.3.8/lib/ruby/gems/3.3.0/gems/activerecord-7.1.5.1/lib/active_record/reflection.rb:464:in `compute_class': Polymorphic associations do not support computing the class. (ArgumentError)
raise ArgumentError, "Polymorphic associations do not support computing the class."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /Users/jpcody/.local/share/mise/installs/ruby/3.3.8/lib/ruby/gems/3.3.0/gems/activerecord-7.1.5.1/lib/active_record/reflection.rb:412:in `klass'
from /Users/jpcody/.local/share/mise/installs/ruby/3.3.8/lib/ruby/gems/3.3.0/gems/active_hash-4.0.0/lib/associations/associations.rb:14:in `has_many'
from /Users/jpcody/Projects/CampusOptics/Code/optics-web/app/models/user.rb:38:in `<class:User>'In our codebase. We follow this association pattern in multiple places, and while I tried to dive in a bit, we're also on the verge of upgrading Rails. For now, I'm going to monkeypatch AH to the old version and see if a newer version of Rails resolves this. But I wanted to go ahead and document the issue in case others run into it. Feel free to close it out if you don't want to have an open issue lying around without a repro case :)
Metadata
Metadata
Assignees
Labels
No labels