Merge pull request #1576 from siddhantbajaj/qr-code
Add token field in ticket
This commit is contained in:
commit
e2bad46d00
8 changed files with 33 additions and 9 deletions
|
|
@ -4,4 +4,19 @@ class PhysicalTicket < ActiveRecord::Base
|
|||
has_one :conference, through: :ticket_purchase
|
||||
has_one :user, through: :ticket_purchase
|
||||
has_many :ticket_scannings
|
||||
|
||||
before_create :set_token
|
||||
|
||||
private
|
||||
|
||||
def set_token
|
||||
self.token = generate_token
|
||||
end
|
||||
|
||||
def generate_token
|
||||
loop do
|
||||
token = SecureRandom.hex(10)
|
||||
break token unless PhysicalTicket.exists?(token: token)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue