Files
aperonight/app/models/ticket.rb
Kevin BATAILLE 30f3ecc6ad refactor(events): replace parties concept with events throughout the application
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

This commit refactors the entire application to replace the 'parties' concept with 'events'. All controllers, models, views, and related files have been updated to reflect this change. The parties table has been replaced with an events table, and all related functionality has been updated accordingly.
2025-08-28 13:20:51 +02:00

23 lines
647 B
Ruby
Executable File

class Ticket < ApplicationRecord
# Associations
belongs_to :user
belongs_to :ticket_type
has_one :event, through: :ticket_type
# Validations
validates :qr_code, presence: true, uniqueness: true
validates :user_id, presence: true
validates :ticket_type_id, presence: true
validates :price_cents, presence: true, numericality: { greater_than: 0 }
validates :status, presence: true, inclusion: { in: %w[active used expired refunded] }
before_validation :set_price_from_ticket_type, on: :create
private
def set_price_from_ticket_type
return unless ticket_type
self.price_cents = ticket_type.price_cents
end
end