Sha256: fde6ef3cdf5ad903f7c46898afbeb5b05f1d9b0d0f2514686d257617167a9041

Contents?: true

Size: 768 Bytes

Versions: 8

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Field model
  #
  class Field < ApplicationRecord
    ##
    # Available field types constant
    #
    CLASSIFICATIONS = %w[string text boolean].freeze

    acts_as_paranoid

    acts_as_list scope: :collection_id,
                 top_of_list: 0,
                 add_new_at: :bottom

    validates :classification, presence: true,
                               inclusion: { in: CLASSIFICATIONS }
    validates :collection_id, presence: true, on: :update
    validates :label, presence: true
    validates :required, inclusion: { in: [true, false] }
    validates :slug, presence: true, uniqueness: { scope: :collection_id }

    belongs_to :collection

    default_scope { order(position: :asc) }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
archangel-0.3.0 app/models/archangel/field.rb
archangel-0.0.8 app/models/archangel/field.rb
archangel-0.0.7 app/models/archangel/field.rb
archangel-0.0.6 app/models/archangel/field.rb
archangel-0.0.5 app/models/archangel/field.rb
archangel-0.0.4 app/models/archangel/field.rb
archangel-0.0.3 app/models/archangel/field.rb
archangel-0.0.2 app/models/archangel/field.rb