activerecord-sortable
activerecord-sortable copied to clipboard
ArgumentError: comparison of NilClass with 1 failed
Getting that error when using config[:append] = true
Temporary fixed it with
next_position = (max_position = sortable_relation.pluck(sortable_position_column)**.map(&:to_i)**.max).present? ? max_position + 1 : 0
in sortable_append_instance method
The problem is that sortable_relation returns existion records + new objects with nil in position column which breaks max.
Please advise.