Sha256: b23f8d0a417cf4acdc80c6e62d724731474a5ded5d117a49785e15d32252e532
Contents?: true
Size: 579 Bytes
Versions: 9
Compression:
Stored size: 579 Bytes
Contents
# frozen_string_literal: true class Album < ActiveRecord::Base self.primary_key = :id before_validation :set_id, :on => :create before_validation :set_integer_id, :on => :create ThinkingSphinx::Callbacks.append( self, :behaviours => [:sql, :real_time, :deltas] ) validates :id, :presence => true, :uniqueness => true validates :integer_id, :presence => true, :uniqueness => true private def set_id self.id = (Album.maximum(:id) || "a").next end def set_integer_id self.integer_id = (Album.maximum(:integer_id) || 0) + 1 end end
Version data entries
9 entries across 9 versions & 1 rubygems