===BeTaggable BeTaggable is a lean mean little tagging machine. * Weights in at 67 lines, this plugin is 1/10th the size of acts_as_taggable gem (2.0.2). * Tag any models you want, no need to create additional join table. * Built in tags_cache column to reduce DB traffic. * Simple installation, run 3 commands and you're ready to tag and roll. === Install 1. install the plugin script/plugin install http://railers.rubyforge.org/svn/plugins/trunk/be_taggable 2. generate, append your model class names to be tagged. script/generate be_taggable_tables Article Bookmark ... 3. rake db:migrate that's it, now let's tag and roll. ===Usage Class TestBook be_taggable # Mark your class be_taggable. ... end book = TestBook.create(:name => "AWDWR") book.tag("programming, rails") # 2 tags added book.tag("agile, rails") # "programming" removed, "agile" added, "rails" untouched. hash = TestBook.tags_count # {"rails" => 1, "agile" => 1} book.tag("") # remove all tags. TestBook.find_tagged_with("rails") # return list of matching book objects. TestBook.find_tagged_with("rails", :offset => 20, :limit => 10) # search with options. ===Usage in template To display model's tags from tags_cache column. <% for tag in YAML::load(article.tags_cache) %> <%= link_to(tag, tagged_articles_path(tag)) # assume route exists %> <% end -%> To show tag cloud
| <%= link_to(pair[0], tagged_articles_path(pair[0])) %> | <%= pair[1] # count %> |