Sha256: 66ab1e83047fc2278232f78159f3d063b3be5d0cbbe749205486366245bfda9e
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
Contents
# frozen_string_literal: true module Archangel ## # Collection model # class Collection < ApplicationRecord acts_as_paranoid before_validation :parameterize_slug after_destroy :column_reset validates :name, presence: true validates :slug, presence: true, uniqueness: { scope: :site_id } belongs_to :site has_many :entries, dependent: :destroy has_many :fields, dependent: :destroy accepts_nested_attributes_for :fields, reject_if: :all_blank, allow_destroy: true ## # Overwrite resource id to `slug` # # @return [String] the aliased resource param # def to_param slug end protected def parameterize_slug self.slug = slug.to_s.downcase.parameterize end def column_reset now = Time.current.to_i self.slug = "#{now}_#{slug}" save end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
archangel-0.4.0 | app/models/archangel/collection.rb |