Class: Skyline::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Skyline::Tag
- Defined in:
- app/models/skyline/tag.rb
Class Method Summary collapse
- .delete_unused_tags ⇒ Object
- .register_taggable_model(klass) ⇒ Object
- .taggable_content_models ⇒ Object
Class Method Details
.delete_unused_tags ⇒ Object
24 25 26 |
# File 'app/models/skyline/tag.rb', line 24 def self.connection.execute("DELETE FROM #{self.table_name} WHERE id NOT IN (SELECT DISTINCT tag_id FROM #{Skyline::AssociatedTag.table_name})") end |
.register_taggable_model(klass) ⇒ Object
18 19 20 21 22 |
# File 'app/models/skyline/tag.rb', line 18 def register_taggable_model(klass) self.taggable_models ||= [] self.taggable_models.delete_if{|c| c.to_s == klass.to_s } # Hack to remove stale object self.taggable_models << klass end |
.taggable_content_models ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/models/skyline/tag.rb', line 9 def taggable_content_models # lazy load all models in /app/models (not recursive) to find all Content models Dir.chdir(File.join(Rails.root, "app", "models")) do Dir.glob("*.rb").map{|f| f.sub(".rb","").camelcase.constantize} end (taggable_models || []).delete_if{|m| m.parents.include?(Skyline) } end |