You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
Our system tracks users' achievements. These may have other achievements as conditions (to track prerequisites). A resource which has_many conditions is called a conditional.
There are several different types of condition and conditional, so the associations are polymorphic in both directions (using active_record-acts_as). This is managed via the conditions table.
With this setup, if achievement 2 has achievement 1 as a condition, Achievement.find(2).conditions.first.actable.achievement would return achievement 1.
The bug happens with the following query, which we use to find all achievemnt conditions of a given achievement (2 in this case):
A bit of context:
Our system tracks users' achievements. These may have other achievements as conditions (to track prerequisites). A resource which
has_many
conditions is called a conditional.There are several different types of condition and conditional, so the associations are polymorphic in both directions (using active_record-acts_as). This is managed via the
conditions
table.With this setup, if achievement 2 has achievement 1 as a condition,
Achievement.find(2).conditions.first.actable.achievement
would return achievement 1.The bug happens with the following query, which we use to find all achievemnt conditions of a given achievement (2 in this case):
It should return achievement 1, but returns achievement 2. The following fixes the problem, however
reload
ing every object is prohibitively expensive:Would anyone have insight into why this happens and if it can be fixed?
There's a minimal Rails project here with the models and schema set up. The problem is also described in Coursemology/coursemology2#443.
Apologies for the exposition. This is an obscure case and I wasn't sure how to frame it more briefly, or come up with a smaller example.
The text was updated successfully, but these errors were encountered: