Sha256: a684e37ec3f109b9574e4874d563d425564f6fc72e1a5185ff7c8f788b3b682d

Contents?: true

Size: 315 Bytes

Versions: 2

Compression:

Stored size: 315 Bytes

Contents

module Sid
  module InstanceMethods
    private

    def set_sid_column
      collection = self.class.where(self.class.scoped_by => self.send(self.class.scoped_by))

      if collection.count.zero?
        self.sid = 1
      else
        self.sid = collection.reorder('id').last.sid + 1
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sid-0.0.2 lib/sid/instance_methods.rb
sid-0.0.1 lib/sid/instance_methods.rb