Module: ActsAsTaggableOnPadrino::Tagger

Defined in:
lib/acts_as_taggable_on_padrino/tagger.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Method Summary collapse

Instance Method Details

#acts_as_tagger(opts = {}) ⇒ Object

Make a model a tagger. This allows an instance of a model to claim ownership of tags.

Example:

class User < ActiveRecord::Base
  acts_as_tagger
end


11
12
13
14
15
16
17
18
19
20
# File 'lib/acts_as_taggable_on_padrino/tagger.rb', line 11

def acts_as_tagger(opts={})
  class_eval do
    has_many :owned_taggings, opts.merge(:as => :tagger, :dependent => :destroy,
                                         :include => :tag, :class_name => "ActsAsTaggableOnPadrino::Tagging")
    has_many :owned_tags, :through => :owned_taggings, :source => :tag, :uniq => true, :class_name => "ActsAsTaggableOnPadrino::Tag"
  end

  include ActsAsTaggableOnPadrino::Tagger::InstanceMethods
  extend ActsAsTaggableOnPadrino::Tagger::ClassMethods
end

#is_tagger?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/acts_as_taggable_on_padrino/tagger.rb', line 22

def is_tagger?
  false
end