Method: Binda::FieldableAssociationHelpers::FieldableTextHelpers#get_text
- Defined in:
- app/models/concerns/binda/fieldable_association_helpers/fieldable_text_helpers.rb
#get_text(field_slug) ⇒ string, error
Get the object related to that field setting If the object doesn’t exists yet it will return nil
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/concerns/binda/fieldable_association_helpers/fieldable_text_helpers.rb', line 12 def get_text(field_slug) obj = Text .includes(:field_setting) .where(fieldable_id: self.id, fieldable_type: self.class.name) .where(binda_field_settings: { slug: field_slug }) .where.not(binda_field_settings: { field_type: "string" }) .first unless obj.nil? # to_s ensures the returned object is class String obj.content.to_s else check_text_error field_slug end end |