Sha256: a514647ac00296f1983c60c7e477ba06d3c4aebe5b3d74f673e54e7654e5c086
Contents?: true
Size: 512 Bytes
Versions: 41
Compression:
Stored size: 512 Bytes
Contents
class FeaturedWork < ActiveRecord::Base FEATURE_LIMIT = 5 validate :count_within_limit, on: :create validates :order, inclusion: { in: Proc.new{ 0..FEATURE_LIMIT } } default_scope { order(:order) } def count_within_limit unless FeaturedWork.can_create_another? errors.add(:base, "Limited to #{FEATURE_LIMIT} featured works.") end end attr_accessor :generic_file_solr_document class << self def can_create_another? FeaturedWork.count < FEATURE_LIMIT end end end
Version data entries
41 entries across 41 versions & 2 rubygems