chore: linting stuff
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
class Ticket < ApplicationRecord
|
||||
# Associations
|
||||
belongs_to :user
|
||||
belongs_to :ticket_type
|
||||
has_one :party, through: :ticket_type
|
||||
|
||||
# Validations
|
||||
validates :qr_code, presence: true, uniqueness: true
|
||||
validates :party_id, presence: 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
|
||||
|
||||
Reference in New Issue
Block a user