chore: Normalize portal slug to nil (#5487)
This commit is contained in:
@@ -11,4 +11,12 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
|
||||
"#{self.class.name}Drop".constantize.new(self)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def normalize_empty_string_to_nil(attrs = [])
|
||||
attrs.each do |attr|
|
||||
self[attr] = nil if self[attr].blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,6 +38,7 @@ class Portal < ApplicationRecord
|
||||
source: :user
|
||||
has_one_attached :logo
|
||||
|
||||
before_validation -> { normalize_empty_string_to_nil(%i[custom_domain homepage_link]) }
|
||||
validates :account_id, presence: true
|
||||
validates :name, presence: true
|
||||
validates :slug, presence: true, uniqueness: true
|
||||
|
||||
Reference in New Issue
Block a user