mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add a :truthy? helper instead of ActiveModel::Type::Boolean.cast
This commit is contained in:
@@ -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?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user