Sha256: 19fe75f662470c44524ef66513b95306ab3651f4e668f341cfb8b117aeb1f2aa

Contents?: true

Size: 688 Bytes

Versions: 8

Compression:

Stored size: 688 Bytes

Contents

# The Tagging join model. This model is automatically generated and added to your app if you run the tagging generator included with has_many_polymorphs.

class Tagging < ActiveRecord::Base 
 
  belongs_to :tag
  belongs_to :taggable, :polymorphic => true
  
  # If you also need to use <tt>acts_as_list</tt>, you will have to manage the tagging positions manually by creating decorated join records when you associate Tags with taggables.
  # acts_as_list :scope => :taggable
    
  # This callback makes sure that an orphaned <tt>Tag</tt> is deleted if it no longer tags anything.
  def before_destroy
    tag.destroy_without_callbacks if tag and tag.taggings.count == 1
  end    
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
railscart-0.0.1 starter-app/app/models/tagging.rb
railscart-0.0.2 starter_app/app/models/tagging.rb
railscart-0.0.3 starter_app/app/models/tagging.rb
railscart-0.0.4 starter_app/app/models/tagging.rb
spree-0.0.5 starter-app/app/models/tagging.rb
spree-0.0.6 starter-app/app/models/tagging.rb
spree-0.0.7 starter-app/app/models/tagging.rb
spree-0.0.8 starter-app/app/models/tagging.rb