lib/acts_as_taggable.rb
def find_tagged_with(tags, options = {})
          options.assert_valid_keys([:match, :order, :user])
          tags = Tag.parse(tags).collect {|t| Tag.select('id').where(:name => t).first}

          group = "#{table_name}_taggings.taggable_id HAVING COUNT(#{table_name}_taggings.taggable_id) >= #{tags.size}" if options[:match] == :all 
          conditions = sanitize_sql(["taggings.tag_id IN (?)", tags])               
          conditions += sanitize_sql([" AND #{table_name}_taggings.user_id = ?", options[:user]]) if options[:user]

          joins("LEFT OUTER JOIN taggings ON taggings.taggable_id = #{table_name}.#{primary_key} AND taggings.taggable_type = '#{name}'").where(conditions).group(group).order(options[:order])
        end
# Pass a tag string, returns taggables that match the tag string.
# 
# Options:
#   :match - Match taggables matching :all or :any of the tags, defaults to :any
#   :user  - Limits results to those owned by a particular user
Pass a tag string, returns taggables that match the tag string.
Pass a tag string returns taggables that match the tag string .
def find_tagged_with(tags, options = {})
          options.assert_valid_keys([:match, :order, :user])
          tags = Tag.parse(tags).collect {|t| Tag.select('id').where(:name => t).first}
          group = "#{table_name}_taggings.taggable_id HAVING COUNT(#{table_name}_taggings.taggable_id) >= #{tags.size}" if options[:match] == :all 
          conditions = sanitize_sql(["taggings.tag_id IN (?)", tags])               
          conditions += sanitize_sql([" AND #{table_name}_taggings.user_id = ?", options[:user]]) if options[:user]
          joins("LEFT OUTER JOIN taggings ON taggings.taggable_id = #{table_name}.#{primary_key} AND taggings.taggable_type = '#{name}'").where(conditions).group(group).order(options[:order])
        end
def find_tagged_with ( tags , options = { } ) options . assert_valid_keys ( [ :match , :order , :user ] ) tags = Tag . parse ( tags ) . collect { | t | Tag . select ( 'id' ) . where ( :name => t ) . first } group = "#{table_name}_taggings.taggable_id HAVING COUNT(#{table_name}_taggings.taggable_id) >= #{tags.size}" if options [ :match ] == :all conditions = sanitize_sql ( [ "taggings.tag_id IN (?)" , tags ] ) conditions += sanitize_sql ( [ " AND #{table_name}_taggings.user_id = ?" , options [ :user ] ] ) if options [ :user ] joins ( "LEFT OUTER JOIN taggings ON taggings.taggable_id = #{table_name}.#{primary_key} AND taggings.taggable_type = '#{name}'" ) . where ( conditions ) . group ( group ) . order ( options [ :order ] ) end
Pass a tag string, returns taggables that match the tag string.
Pass a tag string returns taggables that match the tag string .
tags
options