Changing the scope and resetting the position of an acts_as_positioned object inserts it at the one-before-last position
We have a model where objects should be appended to the list in the new scope when the list scope of the object is changed. We do this by setting the
self.position = nil before it is saved, unfortunately this inserts the object at the one-before-last position.
The following patch solves this problem:
diff --git a/lib/redmine/acts/positioned.rb b/lib/redmine/acts/positioned.rb index 75041fe38..d3959a335 100644 --- a/lib/redmine/acts/positioned.rb +++ b/lib/redmine/acts/positioned.rb @@ -67,7 +67,7 @@ module Redmine def set_default_position if position.nil? - self.position = position_scope.maximum(:position).to_i + (new_record? ? 1 : 0) + self.position = position_scope.maximum(:position).to_i + ((new_record? || position_scope_changed?) ? 1 : 0) end end
This affects trunk.
No data to display