Closed thefloweringash closed 8 years ago
Thanks for that @thefloweringash :)
At a glance, it's probably to do with the hacky way we swap the changed attributes with their original values in order to remove the item from the first list when the scope changes:
# Temporarily swap changes attributes with current attributes
def swap_changed_attributes
@changed_attributes.each do |k, _|
if self.class.column_names.include? k
@changed_attributes[k], self[k] = self[k], @changed_attributes[k]
end
end
end
def check_scope
if scope_changed?
swap_changed_attributes
send('decrement_positions_on_lower_items') if lower_item
swap_changed_attributes
send("add_to_list_#{add_new_at}")
end
end
Are you able to do some testing around that and let me know?
I don't think there'd be much harm is repeating the contents of decrement_positions_on_lower_items
in check_scope
and modifying it for the purpose (moving an item from one scope to the other) instead of trying to hackily reuse the existing method.
@thefloweringash, can you test again on master? I've rewritten that part of the code now to fix a problem with Rails 5.
This resolves the issue for me. Tested against revision a3b1d4ec6a31c713a57d31cdf24e407407c24b5b. Thanks!
That's great to hear! :) You're welcome :)
When moving an item from one list to another list by assigning to the list relation, the positions of the source list aren't updated. Tested under
acts_as_list
d605d17f6966c03d4e547fc43f6c52c774dde706
and version0.7.2
.Test case:
Under rails 4.2.6 I see
While under rails 5.0.0beta3 I see