public
Description: cheat sheet repository for chit
Homepage:
Clone URL: git://github.com/robin/chitsheet.git
robin (author)
Wed Jul 09 03:11:05 -0700 2008
commit  4d546432dd5b473dbbb5883f19cacc71b4599483
tree    d2371207000e34eb8ae02337f9e5c2f03ffdd22d
parent  8b2c5772e458466c24b4c2360fcf24e8b3b72468
chitsheet / acts_as_taggable_on.yml
100644 30 lines (22 sloc) 1.192 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
acts_as_taggable_on: |-
  script/plugin install git://github.com/mbleigh/acts-as-taggable-on.git
  
  class User < ActiveRecord::Base
    acts_as_taggable_on :tags, :skills, :interests, :sports
  end
  
  @user = User.new(:name => "Bobby")
  @user.tag_list = "awesome, slick, hefty" # this should be familiar
  @user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
  @user.skill_list # => ["joking","clowning","boxing"] as TagList
  @user.save
  
  @user.tags # => [<Tag name:"awesome">,<Tag name:"slick">,<Tag name:"hefty">]
  @user.skills # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]
  
  User.find_tagged_with("awesome") # => [@user]
  User.find_tagged_with("joking") # => [@user]
  User.find_tagged_with("awesome", :on => :tags) # => [@user]
  User.find_tagged_with("awesome", :on => :skills) # => []
  
  @frankie = User.create(:name => "Frankie", :skill_list => "joking, flying, eating")
  User.skill_counts # => [<Tag name="joking" count=2>,<Tag name="clowning" count=1>...]
  
  @bobby.skill_counts
  @frankie.skill_counts
  
  (http://www.intridea.com/2007/12/4/announcing-acts_as_taggable_on)