vendor/plugins/acts_as_taggable_on_steroids/lib/acts_as_taggable.rb
# Pass either a tag string, or an array of strings or tags
# 
# Options:
#   :exclude - Find models that are not tagged with the given tags
#   :match_all - Find models that match all of the gievn tags, not just one
#   :conditions - A piece of SQL conditions to add to the query
Pass either a tag string, or an array of strings or tags
Options:
:exclude - Find models that are not tagged with the given tags
:match_all - Find models that match all of the gievn tags, not just one
:conditions - A piece of SQL conditions to add to the query
Pass either a tag string or an array of strings or tags Options : : exclude - Find models that are not tagged with the given tags : match_all - Find models that match all of the gievn tags not just one : conditions - A piece of SQL conditions to add to the query
def find_options_for_tagged_with(tags, options = {})
          tags = TagList.from(tags).names if tags.is_a?(String)
          tags.compact!
          tags.map!(&:to_s)
          return {} if tags.empty?
          conditions = sanitize_sql(["#{table_name}_tags.name #{"NOT" if options.delete(:exclude)} IN (?)", tags])
          conditions << " AND #{sanitize_sql(options.delete(:conditions))}" if options[:conditions]
          group = "#{table_name}_taggings.taggable_id HAVING COUNT(#{table_name}_taggings.taggable_id) = #{tags.size}" if options.delete(:match_all)
          { :select => "DISTINCT #{table_name}.*",
            :joins => "LEFT OUTER JOIN taggings #{table_name}_taggings ON #{table_name}_taggings.taggable_id = #{table_name}.#{primary_key} AND #{table_name}_taggings.taggable_type = '#{name}' " +
                      "LEFT OUTER JOIN tags #{table_name}_tags ON #{table_name}_tags.id = #{table_name}_taggings.tag_id",
            :conditions => conditions,
            :group      => group
          }.update(options)
        end
def find_options_for_tagged_with ( tags , options = { } ) tags = TagList . from ( tags ) . names if tags . is_a? ( String ) tags . compact! tags . map! ( & :to_s ) return { } if tags . empty? conditions = sanitize_sql ( [ "#{table_name}_tags.name #{"NOT" if options.delete(:exclude)} IN (?)" , tags ] ) conditions << " AND #{sanitize_sql(options.delete(:conditions))}" if options [ :conditions ] group = "#{table_name}_taggings.taggable_id HAVING COUNT(#{table_name}_taggings.taggable_id) = #{tags.size}" if options . delete ( :match_all ) { :select => "DISTINCT #{table_name}.*" , :joins => "LEFT OUTER JOIN taggings #{table_name}_taggings ON #{table_name}_taggings.taggable_id = #{table_name}.#{primary_key} AND #{table_name}_taggings.taggable_type = '#{name}' " + "LEFT OUTER JOIN tags #{table_name}_tags ON #{table_name}_tags.id = #{table_name}_taggings.tag_id" , :conditions => conditions , :group => group } . update ( options ) end
Pass either a tag string, or an array of strings or tags
Options:
:exclude - Find models that are not tagged with the given tags
:match_all - Find models that match all of the gievn tags, not just one
:conditions - A piece of SQL conditions to add to the query
Pass either a tag string or an array of strings or tags Options : : exclude - Find models that are not tagged with the given tags : match_all - Find models that match all of the gievn tags not just one : conditions - A piece of SQL conditions to add to the query
tags
<not_specific>
options
<not_specific>