whois update in auction list

This commit is contained in:
olegphenomenon 2023-05-18 10:09:25 +03:00
parent 316f00cadc
commit 06254fb994
3 changed files with 19 additions and 5 deletions

View file

@ -1,4 +1,7 @@
class Auction < ApplicationRecord
after_create :whois_create
after_destroy :whois_destroy
enum status: {
started: 'started',
awaiting_payment: 'awaiting_payment',
@ -116,6 +119,17 @@ class Auction < ApplicationRecord
new_auction.start
end
def whois_create
Whois::Record.transaction do
whois_record = Whois::Record.find_or_create_by!(name: domain)
whois_record.update_from_auction(self)
end
end
def whois_destroy
Whois::Record.find_by(name: domain)&.destroy!
end
private
def generate_registration_code