lib/friendly_id.rb
def find_using_friendly_id(*args)
        case args.first
          when String
            slugs = Slug.find_by_name_and_sluggable_type(args.first, self.base_class.to_s)
          when Array
            slugs = Slug.find_all_by_name_and_sluggable_type(args.first, self.base_class.to_s)
          else
            return false
        end
        
        return false if slugs.blank? || ![*slugs].all?(&:sluggable)
        [*slugs].each { |slug| slug.sluggable.send(:finder_slug=, slug) }
        (slugs.kind_of?(Array)) ? slugs.collect(&:sluggable) : slugs.sluggable
      end
# Finds the record using only the friendly id. If it can't be found
# using the friendly id, then it returns false. If you pass in any
# argument other than an instance of String or Array, then it also 
# returns false. When given as an array will try to find any of the
# records and return those that can be found.
Finds the record using only the friendly id. If it can't be found
using the friendly id, then it returns false. If you pass in any
argument other than an instance of String or Array, then it also
returns false. When given as an array will try to find any of the
records and return those that can be found.
Finds the record using only the friendly id . If it can ' t be found using the friendly id then it returns false . If you pass in any argument other than an instance of String or Array then it also returns false . When given as an array will try to find any of the records and return those that can be found .
def find_using_friendly_id(*args)
        case args.first
          when String
            slugs = Slug.find_by_name_and_sluggable_type(args.first, self.base_class.to_s)
          when Array
            slugs = Slug.find_all_by_name_and_sluggable_type(args.first, self.base_class.to_s)
          else
            return false
        end
        return false if slugs.blank? || ![*slugs].all?(&:sluggable)
        [*slugs].each { |slug| slug.sluggable.send(:finder_slug=, slug) }
        (slugs.kind_of?(Array)) ? slugs.collect(&:sluggable) : slugs.sluggable
      end
def find_using_friendly_id ( * args ) case args . first when String slugs = Slug . find_by_name_and_sluggable_type ( args . first , self . base_class . to_s ) when Array slugs = Slug . find_all_by_name_and_sluggable_type ( args . first , self . base_class . to_s ) else return false end return false if slugs . blank? || ! [ * slugs ] . all? ( & :sluggable ) [ * slugs ] . each { | slug | slug . sluggable . send ( :finder_slug= , slug ) } ( slugs . kind_of? ( Array ) ) ? slugs . collect ( & :sluggable ) : slugs . sluggable end
Finds the record using only the friendly id.
Finds the record using only the friendly id .
args