Sha256: 9804ad9bc637dfd1adc88fce4f33129f48dc372295dfa41689142e4950550d1b
Contents?: true
Size: 501 Bytes
Versions: 2
Compression:
Stored size: 501 Bytes
Contents
class FeaturedWork < ActiveRecord::Base FEATURE_LIMIT = 5 validate :count_within_limit, on: :create validates :order, inclusion: { in: proc { 0..FEATURE_LIMIT } } default_scope { order(:order) } def count_within_limit return if FeaturedWork.can_create_another? errors.add(:base, "Limited to #{FEATURE_LIMIT} featured works.") end attr_accessor :generic_work_solr_document class << self def can_create_another? FeaturedWork.count < FEATURE_LIMIT end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sufia-7.0.0.beta2 | app/models/featured_work.rb |
sufia-7.0.0.beta1 | app/models/featured_work.rb |