Sha256: 0b93e844606ce2a3c7525e96c3f7598a51921e033ded6d6f408c9b02e3a79745
Contents?: true
Size: 345 Bytes
Versions: 5
Compression:
Stored size: 345 Bytes
Contents
module Adminos::MoveTo def self.included(base) base.class_eval do sortable end end def move_to(id) if id.blank? self.move_to_top! else to_position = self.class.where(id: id).pluck(:position).first to_position += 1 if to_position < self.position self.insert_at!(to_position) end end end
Version data entries
5 entries across 5 versions & 1 rubygems