Module BeTaggable::ClassMethods
In: lib/be_taggable.rb

Methods

Public Instance methods

find all rows tagged with given string

[Source]

    # File lib/be_taggable.rb, line 36
36:     def find_tagged_with(tag, options={}) 
37:       find(:all, 
38:            {:select => "m.*",
39:             :joins => %(as m INNER JOIN #{Tagship.table_name} AS ts ON m.id=ts.model_id
40:                              INNER JOIN #{Tag.table_name} AS t ON ts.tag_id=t.id),
41:             :conditions =>["ts.model_type=? and t.name=?", name, tag],
42:             :limit => 20}.merge(options))
43:     end

[Source]

    # File lib/be_taggable.rb, line 24
24:     def split_tag_names(str)
25:       return [] if (str.nil? or str.strip.empty?)
26:       str.downcase.split(",").collect{|x| x.strip if x.strip.size>0 }.uniq.compact.sort
27:     end

returns hash of tag names and count for this model, like {"rails" => 5, "ruby" => 3}

[Source]

    # File lib/be_taggable.rb, line 30
30:     def tags_count(options = {})
31:       rs = Tag.find_all_by_model_type(name, options)
32:       Hash[*rs.collect{|r| [r.name, r.tagships_count.to_i]}.flatten]
33:     end

[Validate]