Add a :truthy? helper instead of ActiveModel::Type::Boolean.cast

This commit is contained in:
Cillian O'Ruanaidh
2025-04-25 14:12:50 +01:00
parent 28c9c53dc0
commit ace5d5eb08

View File

@@ -270,15 +270,15 @@ class Enterprise < ApplicationRecord
end
def remove_logo=(value)
self.logo = nil if ActiveModel::Type::Boolean.new.cast(value)
self.logo = nil if truthy?(value)
end
def remove_promo_image=(value)
self.promo_image = nil if ActiveModel::Type::Boolean.new.cast(value)
self.promo_image = nil if truthy?(value)
end
def remove_white_label_logo=(value)
return if !ActiveModel::Type::Boolean.new.cast(value)
return if !truthy?(value)
self.white_label_logo = nil
self.white_label_logo_link = nil # Link not needed if there's no logo
@@ -492,6 +492,10 @@ class Enterprise < ApplicationRecord
private
def truthy?(value)
ActiveModel::Type::Boolean.new.cast(value)
end
def validate_white_label_logo_link
return if white_label_logo.blank?