-
Type: Bug
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Associations, Query
-
None
If we use .includes on a query it seems to be active for the next queries causing errors on some scenarios like this:
instance = Instance.first instance.deals.includes(:organization).first instance.deals.where(id: 'some-id').only(:name).first ActiveModel::MissingAttributeError: Missing attribute: 'organization_id' from /usr/local/bundle/gems/mongoid-7.4.3/lib/mongoid/attributes.rb:265:in `read_raw_attribute'
As we can see above when the second query is performed it raises an error that shouldn't be raised.
Looks like the `includes(:organization)` was cached.