Class: FieldGroup

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/fields/field_group.rb

Overview

Schema Information

Table name: field_groups

id         :integer         not null, primary key
name       :string(64)
label      :string(128)
position   :integer
hint       :string(255)
created_at :datetime
updated_at :datetime
tag_id     :integer
klass_name :string(32)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.with_tags(tag_ids) ⇒ Object



60
61
62
# File 'app/models/fields/field_group.rb', line 60

def self.with_tags(tag_ids)
  where 'tag_id IS NULL OR tag_id IN (?)', tag_ids
end

Instance Method Details

#core_fieldsObject



52
53
54
# File 'app/models/fields/field_group.rb', line 52

def core_fields
  fields.where(:type => 'CoreField')
end

#custom_fieldsObject



56
57
58
# File 'app/models/fields/field_group.rb', line 56

def custom_fields
  fields.where(:type => 'CustomField')
end

#keyObject



44
45
46
# File 'app/models/fields/field_group.rb', line 44

def key
  "field_group_#{id}"
end

#klassObject



48
49
50
# File 'app/models/fields/field_group.rb', line 48

def klass
  klass_name.constantize
end

#label_i18nObject



64
65
66
# File 'app/models/fields/field_group.rb', line 64

def label_i18n
  I18n.t(name, :default => label)
end