Class: CamaleonCms::TermTaxonomy

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
CustomFieldsRead, Metas
Defined in:
app/models/camaleon_cms/term_taxonomy.rb

Instance Method Summary collapse

Methods included from CustomFieldsRead

#add_custom_field_group, #add_custom_field_to_default_group, #get_field!, #get_field_groups, #get_field_object, #get_field_value, #get_field_values, #get_field_values_hash, #get_fields_object, #get_user_field_groups, #save_field_value, #set_field_values, #update_field_value

Methods included from Metas

#delete_meta, #delete_option, #fix_save_metas_options_no_changed, #get_meta, #get_option, #options, #save_metas_options, #save_metas_options_skip, #set_meta, #set_multiple_options, #set_option

Instance Method Details

#childrenObject

return all children taxonomy sample: sub categories of a category


40
41
42
# File 'app/models/camaleon_cms/term_taxonomy.rb', line 40

def children
  CamaleonCms::TermTaxonomy.where("#{CamaleonCms::TermTaxonomy.table_name}.parent_id = ?", self.id)
end

#in_nav_menu_itemsObject

return all menu items in which this taxonomy was assigned


55
56
57
# File 'app/models/camaleon_cms/term_taxonomy.rb', line 55

def in_nav_menu_items
  CamaleonCms::NavMenuItem.joins(:metas).where("value LIKE ?","%\"object_id\":\"#{self.id}\"%").where("value LIKE ?","%\"type\":\"#{self.taxonomy}\"%").readonly(false)
end

#set_options_from_form(metas = []) ⇒ Object

save multiple option at once sample: set_options_from_form(1, option2: 'b', ..)


46
47
48
49
50
51
52
# File 'app/models/camaleon_cms/term_taxonomy.rb', line 46

def set_options_from_form(metas = [])
  if metas.present?
    metas.each do |key, value|
      self.set_option(key, value)
    end
  end
end

#skip_slug_validation?Boolean

permit to skip slug validations for children models, like menu items

Returns:

  • (Boolean)

60
61
62
# File 'app/models/camaleon_cms/term_taxonomy.rb', line 60

def skip_slug_validation?
  false
end