Tuesday, April 1, 2008

Tagging with has_many_polymorphs

In using HMP earlier, i had discovered that putting the require
statement before the Rails Initializer block gives you a nil error which
is fixed if you shift the require beneath the Rails Initializer block. Then, doing a
>ruby script/generate tagging [model names...]

fires a Couldn't find 'tagging' generator. So i shifted it back up.

Next I wanted to use the Tagging functionality of HMP. I decided to try in on a fresh application so I followed this tutorial
http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/files/README.html
which is a very nice step by step guide.

But i constantly got a 'Could not find tagging generator' error message when I tried a

>ruby script/generate tagging ModelName

I uninstalled the Gem and Installed the plugin which I downloaded from http://webscripts.softpedia.com/script/Internet-Browsers-C-C/has-many-polymorphs-17691.html

but the error still remained.

Finally i wrote to the creator of this plugin, Evan
and put it up on RubyForge

It turned out that the Plugin was really old and I needed a newer version (follow the forum link). [being behind a firewall is really a pathetic situation...]

This got rid of the 'Could not find Tagging generator' error. I went on to try tagging my Models by doing

>ruby script/generate tagging ModelName

which generated a bunch of files and a migration script. Be sure to do a
>rake db:migrate
before you run any tagging related code (even on the ruby console obviously!) unless you want a "Model Cannot be tagged" error. Someone put this too up on Rubyforge.

Now I can successfully Tag my models.




0 comments: