lib/slug.rb
def count_matches(slug_text, sluggable_type, *args)
      return 0 if !Slug.find_by_name(slug_text)
      slugs = with_scope({:find => {:conditions => ["name LIKE '#{slug_text}%' AND sluggable_type = ?", 
          sluggable_type]}}) do
        find(*args)
      end
      count = 0
      slugs.each do |slug|
        count = count + 1 if slug.name =~ /\A#{slug_text}(-[\d]+)*\Z/
      end
      return count
    end
# Count exact matches for a slug. Matches include slugs with the same name
# and an appended numeric suffix, i.e., "an-example-slug" and
# "an-example-slug-2"
#
# The first two arguments are required, after which you may pass in the
# same arguments as ActiveRecord::Base.find.
Count exact matches for a slug.

The first two arguments are required, after which you may pass in the
same arguments as ActiveRecord::Base.find.
Count exact matches for a slug . The first two arguments are required after which you may pass in the same arguments as ActiveRecord :: Base . find .
def count_matches(slug_text, sluggable_type, *args)
      return 0 if !Slug.find_by_name(slug_text)
      slugs = with_scope({:find => {:conditions => ["name LIKE '#{slug_text}%' AND sluggable_type = ?", 
          sluggable_type]}}) do
        find(*args)
      end
      count = 0
      slugs.each do |slug|
        count = count + 1 if slug.name =~ /\A#{slug_text}(-[\d]+)*\Z/
      end
      return count
    end
def count_matches ( slug_text , sluggable_type , * args ) return 0 if ! Slug . find_by_name ( slug_text ) slugs = with_scope ( { :find => { :conditions => [ "name LIKE '#{slug_text}%' AND sluggable_type = ?" , sluggable_type ] } } ) do find ( * args ) end count = 0 slugs . each do | slug | count = count + 1 if slug . name =~ / \A #{ slug_text } (-[ \d ]+)* \Z / end return count end
Count exact matches for a slug.
Count exact matches for a slug .
slug_text
sluggable_type
args