Agile Web Development

Build it. Launch it. Love it.

scalable acts as taggable

Repeated DB entries are no longer taking place. If “atag” is added three times then “atag” gets count=3 in the DB instead of three separate entries. Also, add_tag(‘one two’) is added to the methods so that you can just add a tag or two or three. All words are now separated by ”,” or ” ”.
./script/plugin install svn://rubyforge.org/var/svn/scalabletagging/vendor/plugins/scalable_acts_as_taggable
see for db and setup details
http://rubyforge.org/projects/scalabletagging/
Project sponsored by
http://www.zivity.com

Vitals

Home http://rubyforge.org/projects/scalabletagging/
Repository svn://rubyforge.org/var/svn/scalabletagging/vendor/plugins/scalable_acts_as_taggable
License Rails' (MIT)
Tags Tag_red contribution gree jh mnbm nbmbn open scalable tagalicious ujtnuuuuuuuuu ygyugk zivity
Rating (8 votes)
Owner Matthew Carr
Created 19 April 2007

Comments

  • Avatar
    pireland
    25 May 2007

    I'm not sure what this actually buys. I had the acts_as_taggable_on_steroids already installed.

    By installing this, I was unable to add tags to other items. For some reason, it has a "count" function on the "taggings" column. I'm not sure that makes much sense. When I try to add a tag to additional items, it increases the tagging count.

    Maybe I have something set up incorrectly... but it looks like its functioning as designed. Look at the "before create" function on tagging.rb. Its not looking to see if the tagging is for an different item (Post 1 vs Post 3 for example)

  • Avatar
    soph
    2 June 2007

    The problem is the "before_create" method in Tagging:

    def before_create

    existing_tag = Tag.find(self.tag_id)
    if existing_tag
      taggable = Tagging.find_by_tag_id(existing_tag.id)
      if taggable
        taggable.update_attributes(:count => (taggable.count.to_i + 1) )
        return false
      end
    end 
    return true
    

    end

    It looks for any Tagging with the same Tag.id and then doesn't inserts a new Relation. This is a huge bug, since Tagging is the relation between a taggable an a tag, but everytime ANY taggable uses the same tag the first Tagging Relation gets a count update and the new Tagging Relation isn't inserted.

    Great Work, i had other issues too and after i found this problem i removed scalable_act_as_taggable and switch to acts_as_taggable_on_steroids.

  • Avatar
    7 June 2007

    Soph, you are correct about before_create. I played around with it, and the basic idea of incrementing the count of the taggings instead of just adding another tagging is good. The problem was that the author did not implement it correctly. Here is what I think he originally intended:

    def before_create

    tagging = Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(self.tag_id, self.taggable_id, self.taggable_type)
    if tagging
      tagging.update_attributes(:count => (tagging.count.to_i + 1) )
      return false
    else
      return true
    end
    

    end

  • Avatar
    mcarr
    14 June 2007

    Thanks for the feedback. I've fixed this bug, and made testing work.. and added testing for this particular bug fix. I hadn't used the plugin for more than one class... and all of acts_as_taggable_on_steroids testing was broken after my changes to it. So fixing those was a pain. But its done. So here it is again, with proper functionalality and more testing.

    Ron, I'm pretty sure that the new line

      taggable = Tagging.find(:first, :conditions => { :tag_id => existing_tag.id, :taggable_type => self.taggable_type} )
    

    should suffice. Adding the tagging_id wouldn't make sense since that is what i'm trying to find.

  • Brian
    1 August 2007

    Just downloaded the latest version...I think it's a great idea and I could be using this incorrectly, but the plugin doesn't seem to want to relate more than one record for each tag. I didn't have any problems using acts_as_taggable_on_steroids...

  • Avatar
    4 August 2007

    Brian. that's right. each word is parsed and lowercased. except for "quoted phrases". check out http://www.google.com/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fwww.beautifulsimplethings.com%2F2007%2F6%2F14%2Fusing-scalable-acts-as-taggable&ei=QNizRpGOEaPihQOP6_ngBA&usg=AFQjCNFmgc9vqkCCYE6bV6GgCkjZxP6Now&sig2=jKfz10OU_AXbfyvqS64rCQ

    for usage details. hope this helps. thanks for the feedback.

  • Michael
    21 August 2007

    I am having the same problem as Brian. I have the latest version, but I can't use a tag for multiple objects.

  • Avatar
    2 November 2007

    hey michael, can you be more specific? btw. you can catch me on aim all the time. my aim is lemynshij

  • somaking
    17 January 2008

    There's some bugs in this code. I have spent way too much time on something that should work out of the box.

    One problem I have discovered is you can't assign a tag to more than one object. The bug is in tagging.rb.

    This line: taggable = Tagging.find(:first, :conditions => ['tag_id = ? AND taggable_type = ?', existing_tag.id, self.taggable_type])

    should be this line: taggable = Tagging.find(:first, :conditions => ['tag_id = ? AND taggable_type = ? AND taggable_id = ?', existing_tag.id, self.taggable_type, self.taggable_id])

    I think. Its hard to know exactly. What I do know is the code doesn't work properly.

  • Avatar
    26 January 2008

    thanks somaking. that did it.

    >> p = Photoset.find(2) => #<Photoset id: 2, photographer_id: 7, name: "Classic", created_at: "2007-10-15 18:10:28", updated_at: "2007-12-28 17:08:08", status: "Published", photographer_license_id: 0, processing: false, failed_processing_attempts: 0, photoshoot_id: 2, description: "", published_at: "2007-10-15 18:10:28"> >> p.tag_counts => [] >> p.add_tag('blue baby') => ["blue", "baby"] >> p.tag_counts => [#<Tag id: 3, name: "blue", count: 1>, #<Tag id: 2, name: "baby", count: 1>] >> p = Photoset.find(3) => #<Photoset id: 3, photographer_id: 11, name: nil, created_at: "2007-10-15 20:08:51", updated_at: "2007-12-28 17:08:08", status: "Uploaded", photographer_license_id: 0, processing: false, failed_processing_attempts: 0, photoshoot_id: 3, description: nil, published_at: "2007-10-15 20:08:51"> >> p.add_tag('baby back') => ["baby", "back"] >> p.tag_counts => [#<Tag id: 2, name: "baby", count: 1>, #<Tag id: 4, name: "back", count: 1>] >>

    • remember everyone - keep in mind, if you want Tag counts accross different objects you need to use Tag.find('baby').count - which in the above case would return count: 2
    • otherwise its just a sum for the current object. thanks for everyone's help with this. current revision is 8. please update.

Add a comment