Class: Alchemy::Tag

Inherits:
Gutentag::Tag
  • Object
show all
Defined in:
app/models/alchemy/tag.rb

Class Method Summary collapse

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object



27
28
29
# File 'app/models/alchemy/tag.rb', line 27

def self.ransackable_associations(_auth_object = nil)
  %w[taggings]
end

.ransackable_attributes(_auth_object = nil) ⇒ Object



23
24
25
# File 'app/models/alchemy/tag.rb', line 23

def self.ransackable_attributes(_auth_object = nil)
  %w[created_at id name taggings_count updated_at]
end

.replace(tag, new_tag) ⇒ Object

Replaces tag with new tag on all models tagged with tag.



32
33
34
35
36
37
# File 'app/models/alchemy/tag.rb', line 32

def self.replace(tag, new_tag)
  tag.taggings.collect(&:taggable).each do |taggable|
    taggable.tag_names = taggable.tag_names - [tag.name] + [new_tag.name]
    taggable.save
  end
end