diff options
Diffstat (limited to 'app/models/serverless/domain_cluster.rb')
-rw-r--r-- | app/models/serverless/domain_cluster.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/serverless/domain_cluster.rb b/app/models/serverless/domain_cluster.rb index 1effabf1c22..561bfc65b2b 100644 --- a/app/models/serverless/domain_cluster.rb +++ b/app/models/serverless/domain_cluster.rb @@ -19,7 +19,7 @@ module Serverless validates :uuid, presence: true, uniqueness: true, length: { is: ::Serverless::Domain::UUID_LENGTH }, format: { with: HEX_REGEXP, message: 'only allows hex characters' } - default_value_for(:uuid, allows_nil: false) { ::Serverless::Domain.generate_uuid } + after_initialize :set_uuid, if: :new_record? delegate :domain, to: :pages_domain delegate :cluster, to: :knative @@ -29,5 +29,11 @@ module Serverless .includes(:pages_domain, :knative) .find_by(uuid: uuid) end + + private + + def set_uuid + self.uuid = ::Serverless::Domain.generate_uuid + end end end |