module YeshuaCrm::ActsAsTaggable::Taggable::ClassMethods
Public Class Methods
taggable?()
click to toggle source
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 31 def self.taggable? true end
Public Instance Methods
cached_tag_list_column_name()
click to toggle source
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 37 def cached_tag_list_column_name 'cached_tag_list' end
create_taggable_table(options = {})
click to toggle source
Create the taggable tables
Options hash:¶ ↑
-
:table_name
- use a table name other than viewings
To be used during migration, but can also be used in other places
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 49 def create_taggable_table(options = {}) tag_name_table = options[:tags] || :tags if !self.connection.table_exists?(tag_name_table) self.connection.create_table(tag_name_table) do |t| t.column :name, :string end end taggings_name_table = options[:taggings] || :taggings if !self.connection.table_exists?(taggings_name_table) self.connection.create_table(taggings_name_table) do |t| t.column :tag_id, :integer t.column :taggable_id, :integer # You should make sure that the column created is # long enough to store the required class names. t.column :taggable_type, :string t.column :created_at, :datetime end self.connection.add_index :taggings, :tag_id self.connection.add_index :taggings, [:taggable_id, :taggable_type] end end
drop_taggable_table(options = {})
click to toggle source
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 76 def drop_taggable_table(options = {}) tag_name_table = options[:tags] || :tags if self.connection.table_exists?(tag_name_table) self.connection.drop_table tag_name_table end taggings_name_table = options[:taggings] || :taggings if self.connection.table_exists?(taggings_name_table) self.connection.drop_table taggings_name_table end end
rcrm_acts_as_taggable()
click to toggle source
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 15 def rcrm_acts_as_taggable has_many :taggings, :as => :taggable, :dependent => :destroy, :class_name => '::YeshuaCrm::ActsAsTaggable::Tagging' has_many :tags, :through => :taggings, :class_name => '::YeshuaCrm::ActsAsTaggable::Tag' before_save :save_cached_tag_list after_create :save_tags after_update :save_tags include YeshuaCrm::ActsAsTaggable::Taggable::InstanceMethods extend YeshuaCrm::ActsAsTaggable::Taggable::SingletonMethods alias_method :reload_without_tag_list, :reload alias_method :reload, :reload_with_tag_list class_eval do def self.taggable? true end end end
set_cached_tag_list_column_name(value = nil, &block)
click to toggle source
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 41 def set_cached_tag_list_column_name(value = nil, &block) define_attr_method :cached_tag_list_column_name, value, &block end
taggable?()
click to toggle source
# File lib/yeshua_crm/acts_as_taggable/rcrm_acts_as_taggable.rb, line 11 def taggable? false end