Class: CustomFieldDef

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
RankedModel
Defined in:
app/models/custom_field_def.rb

Overview

Reference: “Handle Multiple Models in One Form” from “Advanced Rails Recipes” and railscasts.com/episodes/403-dynamic-forms and railscasts.com/episodes/196-nested-model-form-revised Note: tried to use coder: JSON for the store, but kept getting a “A JSON text must at least contain two octets!” exception (from new fields) so store in yaml format instead


Constant Summary collapse

FIELD_TYPES =
[ ['Text Field',      'text_field'], 
  ['Text Area',       'text_area'],
  ['Number Field',    'number_field'],
  ['Checkboxes',      'check_box_collection'], 
  ['Radio Buttons',   'radio_buttons'], 
  ['Drop Down Menu',  'select'], 
  ['Divider',         'divider']
  # ['Date/Time Selection', 'date_time'],
  # ['Date Selection', 'date'],
  # ['Country Selection', 'country'],
].freeze

Instance Method Summary collapse

Instance Method Details

#choice_list_arrayObject




43
44
45
# File 'app/models/custom_field_def.rb', line 43

def choice_list_array
  choice_list.split(',').collect { |item| item.strip }
end

#column_nameObject

Text to use for the column during export or in reports. The label will be used if the ‘name’ attribute is blank




50
51
52
# File 'app/models/custom_field_def.rb', line 50

def column_name
  self.name.blank? ? self.label.to_s_default : self.name
end

#divider?Boolean


Returns:

  • (Boolean)


38
39
40
# File 'app/models/custom_field_def.rb', line 38

def divider?
  fieldtype == 'divider'
end