Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting rails tagging plugins to work makes me Hulk-angry

I spent all my time yesterday trying to get ANY Rails tagging plugin to work. While installation was straightforward, I have to say the amount of documentation on how to use any of these plugins was dismal at best...

For the record, I tried:

is_taggable acts_as_taggable_on acts_as_taggable_on_steroids acts_as_taggable_redux

In every instance, the documentation consisted of something like this:

  1. install
  2. undefined magic <---(This is where I fell over, What do I put in my Models, Views and Controllers to make your awesome plugin work? Please tell me!)
  3. Check out all these cool features!

With all of the plugins, I'd ended up dealing with errors like:

NoMethodError in ItemsController#create undefined method `tag_list=' for #<Item:0x47fe848>

I looked up the issues raised on the respective plugin's websites and found that I'm definitely not the only one with these issues. But author support/explanation was not forthcoming even though most of these issues had been raised a while back.

I understand that if I was some kind of Rails guru I could probably get the plugin to work. But I'm not. In my frustration I've decided to just roll my own tagging implementation which seems stupid considering there's so many plugins for tagging available out there...

I also have to say I'm a bit concerned that most of these plugins haven't been maintained in a while. Which makes me wonder if they'll be brought over to Rails 3.

If anyone knows of a tagging plugin for Rails that really works and is easy to implement, please let me know (and if you could point me to a decent tutorial I will give you my undying gratitude as well as some amazing pieces of fluff I found in my pocket just then...)

Otherwise, let this be a plea from all those beginner/intermediate Rails programmers out there to the Rails gods who make and maintain plugins... "We love your work, but please, please provide more documentation!"

like image 951
Ganesh Shankar Avatar asked Feb 18 '10 23:02

Ganesh Shankar


1 Answers

I have used mbleigh's acts-as-taggable-on, and the basic procedure goes:

  1. Add config.gem "acts-as-taggable-on" to environment.rb
  2. Run rake gems:install
  3. Run script/generate acts_as_taggable_on_migration
    • Do any customizations on the migration you might want (you probably won't need to).
  4. Run the migration, rake db:migrate
  5. Add acts_as_taggable_on :your_desired_tag_names to your tagged model (pluralized).
    • I.e. Photo model has :colors tag.
    • If you are getting a NoMethodError, you may have skipped this step.
  6. To set the models tags, use photo.color_list = 'abc, 123, def, 456'
  7. Save the model: photo.save
  8. List the tags: photo.colors
    • You might have to reload the model from the database for the photo.colors method to be available.

Check out the acts-as-taggable-on readme for more instructions/examples.

like image 94
Benjamin Manns Avatar answered Nov 12 '22 23:11

Benjamin Manns