I have used mbleigh's acts-as-taggable-on, and the basic procedure goes:
- Add
config.gem "acts-as-taggable-on"to environment.rb - Run
rake gems:install - Run
script/generate acts_as_taggable_on_migration- Do any customizations on the migration you might want (you probably won't need to).
- Run the migration,
rake db:migrate - Add
acts_as_taggable_on :your_desired_tag_namesto your tagged model (pluralized).- I.e. Photo model has
:colorstag. - If you are getting a
NoMethodError, you may have skipped this step.
- I.e. Photo model has
- To set the models tags, use
photo.color_list = 'abc, 123, def, 456' - Save the model:
photo.save - List the tags:
photo.colors- You might have to reload the model from the database for the
photo.colorsmethod to be available.
- You might have to reload the model from the database for the
Check out the acts-as-taggable-on readme for more instructions/examples.
Benjamin Manns
2010-02-19 00:59:33