Spraypaint plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://svn.tomafro.net/rails/plugins/spraypaint/
Some examples
a) Most tagging queries wrap around the standard finder methods. So the following are all valid:
# Finds with added conditions, limit and offsets
Pub.find :all, :tagged_with_all => ['cosy', 'wood fire', 'real ale'], :conditions => {:city_id => 'london'}, :limit => 20, :offset => 10
# Calculations based on tags
Pub.sum :turnover, :tagged_with_any => 'football'
# Finds through associations
City.find_by_name('London').pubs.find(:all, :tagged_with_any => ['overpriced'])
b) While there is a proper tagging model hidden away, all manipulation is done through strings:
Within your project, generate a migration to create spraypaint specific tables:
script/generate spraypaint_migration rake db:migrate
p = Pub.create :tags => ['dark', 'old men', 'fights'] p.tags << 'wetherspoons' p.save p.tag_string = "dark, old men, fights" p.save
c) There's some rudimentary support for machine tagging:
Film.create :tags => ['film:director:coens'] Film.find :all, :tagged_with_any => {:namespace => :film} Film.find :all, :tagged_with_any => {:namespace => :film, :predicate => :director}
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | Back in time (1 older version) | Last edited by: tomafro, about 1 year ago

