Sha256: 9c77c83ef009b4b6682c8cbfbd8c722cf25f26b44b17b275d30398a39736c8b2
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
module ActsAsTaggableOnPadrino module Taggable def taggable? false end ## # This is an alias for calling <tt>acts_as_taggable_on :tags</tt>. # # Example: # class Book < ActiveRecord::Base # acts_as_taggable # end def acts_as_taggable acts_as_taggable_on :tags end ## # Make a model taggable on specified contexts. # # @param [Array] tag_types An array of taggable contexts # # Example: # class User < ActiveRecord::Base # acts_as_taggable_on :languages, :skills # end def acts_as_taggable_on(*tag_types) tag_types = tag_types.to_a.flatten.compact.map {|type| type.to_sym } if taggable? write_inheritable_attribute(:tag_types, (self.tag_types + tag_types).uniq) else write_inheritable_attribute(:tag_types, tag_types) write_inheritable_attribute(:tag_table_name, ActsAsTaggableOnPadrino::Tag.table_name) write_inheritable_attribute(:tagging_table_name, ActsAsTaggableOnPadrino::Tagging.table_name) class_inheritable_reader(:tag_types, :tag_table_name, :tagging_table_name) Tag.like_operator = 'ILIKE' if Tag.using_postgresql? class_eval do has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => "ActsAsTaggableOnPadrino::Tagging" has_many :base_tags, :through => :taggings, :source => :tag, :class_name => "ActsAsTaggableOnPadrino::Tag" def self.taggable? true end include ActsAsTaggableOnPadrino::Taggable::Core include ActsAsTaggableOnPadrino::Taggable::Collection include ActsAsTaggableOnPadrino::Taggable::Cache include ActsAsTaggableOnPadrino::Taggable::Ownership include ActsAsTaggableOnPadrino::Taggable::Related end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts-as-taggable-on-padrino-0.1.2 | lib/acts_as_taggable_on_padrino/taggable.rb |