Class: DynamicFieldsets::FieldRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/dynamic_fieldsets/field_record.rb

Overview

Stores a single record’s answer to a field in a fieldset Fields with multiple answers should have multiple records in this model

Instance Method Summary collapse

Instance Method Details

#fieldField

A record can only be associated with Field children

Returns:

  • (Field)

    Alias for fieldset_child.child.



25
26
27
# File 'app/models/dynamic_fieldsets/field_record.rb', line 25

def field
  self.fieldset_child.child
end

#type_of_fieldset_childObject

make sure the fieldset child has the type field does not explicitly check to make sure the fieldset_child exists, still have to validate presence



16
17
18
19
20
21
# File 'app/models/dynamic_fieldsets/field_record.rb', line 16

def type_of_fieldset_child
  # yet another casualty of me not understanding how the objects are getting duplicated in development (JH 3-6-2012)
  if self.fieldset_child && !self.fieldset_child.child.class.superclass.to_s.eql?("DynamicFieldsets::Field")
    self.errors.add(:fieldset_child, "The fieldset child must refer to a Field object")
  end
end