scinote-web/app/models/form_field.rb
2024-12-10 12:22:56 +01:00

15 lines
530 B
Ruby

# frozen_string_literal: true
class FormField < ApplicationRecord
include Discard::Model
belongs_to :form
belongs_to :created_by, class_name: 'User'
belongs_to :last_modified_by, class_name: 'User'
validates :name, length: { minimum: Constants::NAME_MIN_LENGTH, maximum: Constants::NAME_MAX_LENGTH }
validates :description, length: { maximum: Constants::NAME_MAX_LENGTH }
validates :position, presence: true, uniqueness: { scope: :form }
acts_as_list scope: :form, top_of_list: 0, sequential_updates: true
end