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
Having a record that is not set to a position defaults to :last, but this causes the record to inadvertently be moved to the last position whenever there is an update to the already saved record.
Specifically, this case will give an odd result:
classFoo < ActiveRecord::BaseincludeRankedModelranks:row_orderendr=Foo.create()other=Foo.create()r.update(some_field: "new_value")# <= This line will also update the row_order field
This same behavior does not occur if you fetch the record from the database directly - the row_order will be static in that case.
I ran into this issue with some usage of the pattern in tests to create the object, then update it, reload, and verify the ordering.
The text was updated successfully, but these errors were encountered:
That's interesting. I guess it's a downside of the underlying database state changing at save but not being updated in the object itself. I'm not sure what the answer is here. Did you want to explore a PR around populating the row_order on save if it's inferred?
Having a record that is not set to a position defaults to
:last
, but this causes the record to inadvertently be moved to the last position whenever there is an update to the already saved record.Specifically, this case will give an odd result:
This same behavior does not occur if you fetch the record from the database directly - the
row_order
will be static in that case.I ran into this issue with some usage of the pattern in tests to create the object, then update it, reload, and verify the ordering.
The text was updated successfully, but these errors were encountered: