# ANN: Spraypaint - yet another tagging library for rails

**URL:** <https://www.ruby-forum.com/t/ann-spraypaint-yet-another-tagging-library-for-rails/121087>\
**Category:** Rails\
**Created:** [November 23, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/ann-spraypaint-yet-another-tagging-library-for-rails/121087 "2007-11-23T16:23:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomafro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tomafro](https://www.ruby-forum.com/u/tomafro)\
**Post date:** [November 23, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/ann-spraypaint-yet-another-tagging-library-for-rails/121087/1 "2007-11-23T16:23:41Z")

</div>

I’ve just open-sourced and released spraypaint, a tagging plugin I’ve  
developed. I can’t claim it’s better than all other tagging plugins  
out there (and there are certainly quite a few) but I think it’s  
different enough that other people might find it useful. Here are  
some of those differences:

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:

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}

If any of this sounds interesting, take a look at:

[http://svn.tomafro.net/plugins/spraypaint/trunk](http://svn.tomafro.net/plugins/spraypaint/trunk)

I’d be interested in all comments and feedback

Tom

---

<div class="post-metadata">

**Author:** ![tomafro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tomafro](https://www.ruby-forum.com/u/tomafro)\
**Post date:** [November 26, 2007, 6:14pm UTC](https://www.ruby-forum.com/t/ann-spraypaint-yet-another-tagging-library-for-rails/121087/2 "2007-11-26T18:14:26Z")

</div>

Following some advice, I’ve moved the code to  
[http://svn.tomafro.net/rails/plugins/spraypaint](http://svn.tomafro.net/rails/plugins/spraypaint) so it works nicely  
with script/plugin install.

I’ve also backported the code to 1.2.6 as apparently not everyone  
develops their apps on the bleeding edge 😉

I’d still really appreciate any more comments, criticism or even abuse  
you’d all care to send my way.

Tom

---

<div class="post-metadata">

**Author:** ![tomafro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tomafro](https://www.ruby-forum.com/u/tomafro)\
**Post date:** [November 26, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/ann-spraypaint-yet-another-tagging-library-for-rails/121087/3 "2007-11-26T20:01:39Z")

</div>

I’ve added it to RailsLodge  
[http://www.railslodge.com/plugins/831-spraypaint](http://www.railslodge.com/plugins/831-spraypaint)

Tom W. wrote:

> Following some advice, I’ve moved the code to  
> [http://svn.tomafro.net/rails/plugins/spraypaint](http://svn.tomafro.net/rails/plugins/spraypaint) so it works nicely  
> with script/plugin install.
> 
> I’ve also backported the code to 1.2.6 as apparently not everyone  
> develops their apps on the bleeding edge 😉
> 
> I’d still really appreciate any more comments, criticism or even abuse  
> you’d all care to send my way.
> 
> Tom

---

<div class="post-metadata">

**Author:** ![tomafro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@tomafro](https://www.ruby-forum.com/u/tomafro)\
**Post date:** [November 27, 2007, 10:34am UTC](https://www.ruby-forum.com/t/ann-spraypaint-yet-another-tagging-library-for-rails/121087/4 "2007-11-27T10:34:15Z")

</div>

On 11/26/07, Scott A S [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve added it to RailsLodge  
> [http://www.railslodge.com/plugins/831-spraypaint](http://www.railslodge.com/plugins/831-spraypaint)

Thank you - very much appreciated.

Tom
