60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/closure_tree/numeric_order_support.rb', line 60
def reorder_with_parent_id(parent_id, minimum_sort_order_value = nil)
return if parent_id.nil? && dont_order_roots
scope = model_class.
where(parent_column_sym => parent_id).
order(nulls_last_order_by)
if minimum_sort_order_value
scope = scope.where("#{quoted_order_column} >= #{minimum_sort_order_value}")
end
scope.each_with_index do |ea, idx|
ea.update_order_value(idx + minimum_sort_order_value.to_i)
end
end
|