Module: FatFreeCRM::Fields::SingletonMethods
- Defined in:
- lib/fat_free_crm/fields.rb
Instance Method Summary collapse
- #field_groups ⇒ Object
- #fields ⇒ Object
-
#ransack_column_select_options ⇒ Object
Shows custom field select options in ransack search form.
- #serialize_custom_fields! ⇒ Object
Instance Method Details
#field_groups ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/fat_free_crm/fields.rb', line 26 def field_groups # catches cases where this code runs before database has been created or migrated return [] unless ActiveRecord::Base.connection.active? return [] unless ActiveRecord::Base.connection.table_exists?(:field_groups) FieldGroup.where(klass_name: name).order(:position) rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid [] end |
#fields ⇒ Object
36 37 38 |
# File 'lib/fat_free_crm/fields.rb', line 36 def fields field_groups.map(&:fields).flatten end |
#ransack_column_select_options ⇒ Object
Shows custom field select options in ransack search form
47 48 49 50 51 52 53 54 55 |
# File 'lib/fat_free_crm/fields.rb', line 47 def field_groups.each_with_object({}) do |group, hash| group.fields.select { |f| f.collection.present? }.each do |field| hash[field.name] = field.collection.each_with_object({}) do |option, | [option] = option end end end end |
#serialize_custom_fields! ⇒ Object
40 41 42 43 44 |
# File 'lib/fat_free_crm/fields.rb', line 40 def serialize_custom_fields! fields.each do |field| serialize(field.name.to_sym, Array) if field.as == 'check_boxes' end end |