Class: SchedulerBookingQuestion

Inherits:
ApplicationRecord show all
Defined in:
app/models/scheduler_booking_question.rb

Overview

== Schema Information

Table name: scheduler_booking_questions
Database name: primary

id :bigint not null, primary key
active :boolean default(TRUE), not null
field_type :string default("short_text"), not null
label :string not null
position :integer default(0), not null
required :boolean default(FALSE), not null
created_at :datetime not null
updated_at :datetime not null
scheduler_booking_page_id :bigint not null

Indexes

idx_scheduler_questions_page_position (scheduler_booking_page_id,position)

Foreign Keys

fk_rails_... (scheduler_booking_page_id => scheduler_booking_pages.id) ON DELETE => cascade

Instance Attribute Summary collapse

Belongs to collapse

Class Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#field_typeObject (readonly)



29
# File 'app/models/scheduler_booking_question.rb', line 29

validates :field_type, presence: true, inclusion: { in: %w[short_text long_text] }

#labelObject (readonly)



28
# File 'app/models/scheduler_booking_question.rb', line 28

validates :label, presence: true

#positionObject (readonly)



30
# File 'app/models/scheduler_booking_question.rb', line 30

validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }

Class Method Details

.activeActiveRecord::Relation<SchedulerBookingQuestion>

A relation of SchedulerBookingQuestions that are active. Active Record Scope

Returns:

See Also:



32
# File 'app/models/scheduler_booking_question.rb', line 32

scope :active, -> { where(active: true) }

.orderedActiveRecord::Relation<SchedulerBookingQuestion>

A relation of SchedulerBookingQuestions that are ordered. Active Record Scope

Returns:

See Also:



33
# File 'app/models/scheduler_booking_question.rb', line 33

scope :ordered, -> { order(:position) }

Instance Method Details

#scheduler_booking_pageSchedulerBookingPage



26
# File 'app/models/scheduler_booking_question.rb', line 26

belongs_to :scheduler_booking_page