Sha256: da0a8144f0d3d14ab4d7657e815f943ecb194e06136f8b628e2b4bde97aa8749
Contents?: true
Size: 371 Bytes
Versions: 6
Compression:
Stored size: 371 Bytes
Contents
module Kms module Positioned extend ActiveSupport::Concern included do before_create :set_position end def set_position if parent.present? max = parent.children.maximum(:position) else max = self.class.where('ancestry IS ?', nil).maximum(:position) end self.position = max ? max + 1 : 0 end end end
Version data entries
6 entries across 6 versions & 1 rubygems