Module ActiveRecord::Acts::Taggable::InstanceMethods
In: lib/taggable.rb

Methods

Public Instance methods

Handles clearing all associated tags

This method applies tags to the target object, by parsing the tags parameter into Tag object instances and adding them to the tag collection of the object. If the tag name already exists in the tags table, it just adds a relationship to the existing tag record. If it doesn‘t exist, it then creates a new Tag record for it.

The tags parameter can be a String, Array or a Proc object. If it‘s a String, it‘s split using the +:separator+ specified in the options hash. If it‘s an Array it is flattened and compacted. Duplicate entries will be removed as well. Tag names are also stripped of trailing and leading whitespace. If a Proc is passed, the proc should split the string in any way it wants and return an array of strings.

The options hash has the following parameters:

+:separator+ => defines the separator (String or Regex) used to split the tags parameter and defaults to ’ ’ (space and line breaks).

+:clear+ => defines whether the existing tag collection will be cleared before applying the new tags passed. Defaults to false.

Returns an array of strings containing the tags applied to this object. If reload is true, the tags collection is reloaded.

Clears the current tags collection and sets the tag names for this object. Equivalent of calling tag(…, :clear => true)

Another way of appending tags to a existing tags collection is by using the +<<+ or concat method on tag_names, which is equivalent of calling tag(…, :clear => false).

This method removes tags from the target object, by parsing the tags parameter into Tag object instances and removing them from the tag collection of the object if they exist.

The tags parameter can be a String, Array or a Proc object. If it‘s a String, it‘s split using the +:separator+ specified in the options hash. If it‘s an Array it is flattened and compacted. Duplicate entries will be removed as well. Tag names are also stripped of trailing and leading whitespace. If a Proc is passed, the proc should split the string in any way it wants and return an array of strings.

The options hash has the following parameters:

+:separator+ => defines the separator (String or Regex) used to split the tags parameter and defaults to ’ ’ (space and line breaks).

Calls find_related_tagged passing self as the related parameter.

Checks to see if this object has been tagged with tag_name. If reload is true, reloads the tag collection before doing the check.

Checks to see if this object has been tagged with all tags - they can be a string,or list The options hash has the following parameters: +:separator+ => defines the separator (String or Regex) used to split the tags parameter and defaults to ’ ’ (space and line breaks). +:reload+ => That forces the tag names to be reloaded first

Checks to see if this object has been tagged with any tags - they can be a string,or list The options hash has the following parameters: +:separator+ => defines the separator (String or Regex) used to split the tags parameter and defaults to ’ ’ (space and line breaks). +:reload+ => That forces the tag names to be reloaded first

[Validate]