Sha256: 1a72d1a386e1a063edb1c0d89ae21b6c67f0c3929a240532e124953752fc28e0

Contents?: true

Size: 541 Bytes

Versions: 1

Compression:

Stored size: 541 Bytes

Contents

require 'active_support/concern'

module Gutentag::ActiveRecord
  extend ActiveSupport::Concern

  module ClassMethods
    def has_many_tags
      has_many :taggings, :class_name => 'Gutentag::Tagging', :as => :taggable,
        :dependent => :destroy
      has_many :tags,     :class_name => 'Gutentag::Tag',
        :through => :taggings

      after_save Gutentag::Persistence

      attr_writer :tag_names
    end
  end

  def reset_tag_names
    @tag_names = nil
  end

  def tag_names
    @tag_names ||= tags.collect(&:name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gutentag-0.3.0 lib/gutentag/active_record.rb