Sha256: 31c9a15738d0077589f9d5b86eb396695447fa79bbda2e685672ecb37a2d48a6

Contents?: true

Size: 780 Bytes

Versions: 11

Compression:

Stored size: 780 Bytes

Contents

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
class Tag < ActsAsTaggableOn::Tag
  before_destroy :no_associated_field_groups

  # Don't allow a tag to be deleted if it is associated with a Field Group
  def no_associated_field_groups
    FieldGroup.find_all_by_tag_id(self).none?
  end

  # Returns a count of taggings per model klass
  # e.g. {"Contact" => 3, "Account" => 1}
  def model_tagging_counts
    Tagging.where(:tag_id => id).count(:group => :taggable_type)
  end

  ActiveSupport.run_load_hooks(:fat_free_crm_tag, self)
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fat_free_crm-0.13.6 app/models/polymorphic/tag.rb
fat_free_crm-0.13.5 app/models/polymorphic/tag.rb
fat_free_crm-0.13.4 app/models/polymorphic/tag.rb
fat_free_crm-0.13.3 app/models/polymorphic/tag.rb
fat_free_crm-0.13.2 app/models/polymorphic/tag.rb
fat_free_crm-0.12.3 app/models/polymorphic/tag.rb
fat_free_crm-0.12.2 app/models/polymorphic/tag.rb
fat_free_crm-0.13.1 app/models/polymorphic/tag.rb
fat_free_crm-0.12.1 app/models/polymorphic/tag.rb
fat_free_crm-0.13.0 app/models/polymorphic/tag.rb
fat_free_crm-0.12.0 app/models/polymorphic/tag.rb