Sha256: 1c38a9dd79cb7f2bb2d92aa29ad3dbfb2cfac992f4e6e977342caebfc5a63d83
Contents?: true
Size: 660 Bytes
Versions: 12
Compression:
Stored size: 660 Bytes
Contents
# frozen_string_literal: true require 'acts_as_list' module Lcms module Engine class DownloadCategory < ApplicationRecord has_many :resource_downloads default_scope { order(:position) } acts_as_list validates :title, uniqueness: true, presence: true before_save :unique_bundle def self.bundle where(bundle: true).first end private def unique_bundle # we need the try here, otherwise this will fail when migrating the first time. self.class.where.not(id: id).where(bundle: true).update_all(bundle: false) if try(:bundle) && bundle_changed? end end end end
Version data entries
12 entries across 12 versions & 1 rubygems