Method: Binda::FieldableAssociationHelpers::FieldableSvgHelpers#has_svg

Defined in:
app/models/concerns/binda/fieldable_association_helpers/fieldable_svg_helpers.rb

#has_svg(field_slug) ⇒ boolean

Check if the field has an attached audio

Parameters:

  • field_slug (string)

    The slug of the field setting

Returns:

  • (boolean)

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
# File 'app/models/concerns/binda/fieldable_association_helpers/fieldable_svg_helpers.rb', line 8

def has_svg(field_slug)
	obj = self.svgs.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
	# Alternative query
	# obj = Image.where(field_setting_id: FieldSetting.get_id( field_slug ), fieldable_id: self.id, fieldable_type: self.class.to_s ).first
	raise ArgumentError, "There isn't any svg associated to the current slug (#{field_slug}) on instance (#{self.class.name} ##{self.id}).", caller if obj.nil?
	return obj.svg.present?
end