Sporkmonger

purveyor of fabulously ambiguous eating utensils

TagTools project

Posted by sporkmonger
Written August 28th, 2005

Well, I woke up this morning to see an entry on tagging with Rails in NewNewsWire. I commented about the implementation on the ROR weblog.

So anyways, I’ve been working for the last week or so on a tagging system for Rails. When I saw the post I decided to try to finish my code before the day was over. 200mg of caffeine later… well… it’s now 5:30am. I finally got it clean enough for public consumption, though it may still have at least a couple of bugs to work out. Lots more features coming soon, including related tags.

Have fun with the thing! Let me know if you have any issue with it. I’ll probably wake up in a week or two to deal with the bugs. Good night!

TagTools documentation.

  1. Written August 28th, 2005 at 08:07 PM

    If you had come up with something like FileColumn too, nearly ALL of the heavy lifting of my upcoming app would be taken care of by your code…

    FeedTools saved me a bunch of time, and TagTools will replace a much less flexible approach I’d coded already.

    I had been planning to use the acts_as_taggable mixin mentioned yesterday, but this looks a lot more complete.

    Thanks!

  2. Written August 29th, 2005 at 07:15 PM

    Happy to help!

  3. Dema :
    Written August 30th, 2005 at 11:33 AM

    Hi Bob, just wanted to let you know that I dropped a quick comment on the original RoR weblog post about the subject. Thanks for your valuable input on the subject.

  4. Written August 30th, 2005 at 03:59 PM

    Thanks for the heads-up Demetrius. Like I said, didn’t mean to be harsh or anything, just a little worried about this kind of thing being integrated directly into Rails, especially if there’s a lot of improvements still to be made. Your code was really clean and well-commented, and aspects of it definately made their way into my own implementation. And it’s not like first versions are ever perfect anyways (mine certainly isn’t).

  5. Dema Dema :
    Written August 31st, 2005 at 02:35 AM

    Bob, just a little correction about your comment on the RoR post. My mixin does allow tags with spaces, as you can use a :separator option for custom splitting as well as pass in an already splitted array. Just look at the RDoc and you’ll see.

    Also, I took a good look at your code and although it seems fairly complete, one thing really got me worried about it: there’s a lot of duplicated code, both from the original AR associations code and also within itself. Global and user-specific tagging share lots of common code that’s duplicated right now.

    I think you’ll probably take the time in the future to remove the code duplication, although the part copied directly from the original AR associations might be hard to clean.

    Anyway, there were a few good ideas I could gather from your code, specially the tag querying, but I definately want to keep my mixin on much lower complexity and under 200 LOC, otherwise I won’t trust it! ;-)

    I am taking a radically different approach for implementing user-specific tagging that might allow me to do that in a very clean way and also other things that got suggested on my blog, such as integrating other acts.

    If I can’t do that, I’ll just give up and use yours instead. ;-)

    Good luck on your attempt, I’ll keep an eye on your work. Cheers.

  6. Written August 31st, 2005 at 09:20 AM

    Demetrius, I’m well aware of the duplicated code. Originally, the user tag collection inheritted from the global tag collection. Unfortunately, there was some kind of conflict, and I didn’t have the time to sort it out, so I separated the two. When I do figure it out, it’ll go back to the way it was.

    Also, while it does, at first glance, look like there’s a lot taken from the AR collections, there shouldn’t be anything in there that couldn’t have just been inheritted from something else. Unfortunately, there’s quite a few spots where I had to make one line changes to a method, and in the process, basically had to duplicate most of the functionality. I don’t really know of any good way of avoiding this problem.

    As for the obviously greater complexity in my code, I’ll probably just pull out a really big set of unit tests.

  7. Saimon :
    Written September 5th, 2005 at 01:36 AM

    Hi Bob,

    I’ve been playing around with this and it’s really quite usefull.

    Thanks,

    Saimon

    P.S. Found a bug in delete_records() which I’ve patched (In ruby forge bug tracker).

  8. Written September 8th, 2005 at 01:55 PM

    Oh, excellent, thanks. I’ll go take a look.

Leave a Response

NOTE: I'm afraid Javascript needs to be on in order to comment.

Comments should be formatted using Textile.

Ruby code should be enclosed within a <macro:code lang="ruby"> element. Other languages are supported. For output you can simply omit the lang attribute.