Sha256: 0d175d3f5ddcff6fab931da4526729225304685674c883ec0c42b279c309b301

Contents?: true

Size: 642 Bytes

Versions: 9

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

# == Schema Information
#
# Table name: tags
#
#  id             :integer          not null, primary key
#  name           :string
#  taggings_count :integer          default(0)
#

# Just holds some useful tag methods.
# The original Tag model is ActsAsTaggableOn::Tag
module Alchemy
  class Tag < ActsAsTaggableOn::Tag
    # Replaces tag with new tag on all models tagged with tag.
    def self.replace(tag, new_tag)
      tag.taggings.collect(&:taggable).each do |taggable|
        taggable.tag_list.delete(tag.name)
        taggable.tag_list << new_tag.name
        taggable.save
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-4.0.6 app/models/alchemy/tag.rb
alchemy_cms-4.0.5 app/models/alchemy/tag.rb
alchemy_cms-4.0.4 app/models/alchemy/tag.rb
alchemy_cms-4.0.3 app/models/alchemy/tag.rb
alchemy_cms-4.0.2 app/models/alchemy/tag.rb
alchemy_cms-4.0.1 app/models/alchemy/tag.rb
alchemy_cms-4.0.0 app/models/alchemy/tag.rb
alchemy_cms-4.0.0.rc2 app/models/alchemy/tag.rb
alchemy_cms-4.0.0.rc1 app/models/alchemy/tag.rb