fix : ticket order new
This commit is contained in:
@@ -19,6 +19,8 @@ class Ticket < ApplicationRecord
|
||||
scope :active, -> { where(status: "active") }
|
||||
scope :expired_drafts, -> { joins(:order).where(status: "draft").where("orders.expires_at < ?", Time.current) }
|
||||
|
||||
# Set default values before validation
|
||||
before_validation :set_defaults, on: :create
|
||||
before_validation :set_price_from_ticket_type, on: :create
|
||||
before_validation :generate_qr_code, on: :create
|
||||
|
||||
@@ -83,4 +85,8 @@ class Ticket < ApplicationRecord
|
||||
order.earning&.recalculate!
|
||||
end
|
||||
end
|
||||
|
||||
def set_defaults
|
||||
self.status ||= "draft"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user