There are a lot of internal changes, but default behaviour should be compatible with a default configuration of the original gem.
More documentation will follow, but for now, here’s how you can configure and use this fork:
# config/initializers/is_taggable.rb: IsTaggable.configure_tag_list(:standard, :delimiter => ':', :output_delimiter => ' : ') # - change style from 'tag1 tag2 tag3' to 'tag1 : tag2 : tag3' IsTaggable.configure_tag_list(:youtube) # - make it similar to youtube movies tags, e.g. 'tag1 "several words in tag2" tag3' IsTaggable.configure_tag_list(:youtube, :normalize_with => :downcase) # - the same thing, plus tags will be downcased # app/models/some_model.rb: class SomeModel < ActiveRecord::Base is_taggable :tags, :langs end
Below is the original documentation, it is not completely relevant now.
At last, a short and sweet tagging implementation that you can easily modify and extend.
Most of the plugins out there are on steroids or messing directly with SQL, a known gateway drug.
We wanted a more sober plugin that would handle new functionality without breaking a sweat. Some plugins had minimal or no tests gasp. They were so messed up that operating would likely cause internal bleeding.
So, we crafted the plugin we needed with the functionality we were looking for: tag kinds. It’s small and healthy. So, it should be a good base to build on.
After generating the migration:
$ script/generate is_taggable_migration $ rake db:migrate
All you need is the ‘is_taggable’ declaration in your models:
class User < ActiveRecord::Base is_taggable :tags, :languages end
In your forms, add a text fields for “tag_list” and/or “language_list” (matching the example model above):
<%= f.text_field :tag_list %>
Calling is_taggable with any arguments defaults to a tag_list. Instantiating our polyglot user is easy:
User.new :tag_list => "rails, giraffesoft", :language_list => "english, french, spanish, latin, esperanto, tlhIngan Hol"
A comma is the default tag separator, but this can be easily changed:
IsTaggable::TagList.delimiter = " "
You can also specify an output delimiter:
IsTaggable::TagList.output_delimiter = ", " u = User.create :language_list => "english,french, german" u.language_list.to_s # => "english, french, german"
This example formats the list using standard punctuation and spacing, but doesn’t require it from user input.
The delimiter can be a regular expression, in which case an output delimiter is necessary:
IsTaggable::TagList.delimiter = /[, ]/ IsTaggable::TagList.output_delimiter = " " u = User.create :language_list => "english, french" u.language_list.to_s # => "english french" u = User.create :language_list => "english french" u.language_list.to_s # => "english french"
In this example, your users can include commas (which will be ignored) or not.
$ sudo gem install is_taggable
As a rails gem dependency:
config.gem 'is_taggable'
Or get the source from github:
$ git clone git://github.com/giraffesoft/is_taggable.git
(or fork it at github.com/giraffesoft/is_taggable)
is_taggable was created, and is maintained by Daniel Haran and James Golick.
is_taggable is available under the MIT License