Sha256: 9748c3e570acd0ffbefe8132e4c09029a0b85fd97f71696ed71a45cc24e77bce

Contents?: true

Size: 614 Bytes

Versions: 1

Compression:

Stored size: 614 Bytes

Contents

module SluggableFinder
  # This module is included by the base class as well as AR asociation collections
  #
  module Finder
    
    def find_with_slug(*args)
      if (args.first.is_a?(String) and !(args.first =~ /\A\d+\Z/))#only contain digits
          options = {:conditions => ["#{ sluggable_finder_options[:to]} = ?", args.first]}
          first(options) or 
            raise SluggableFinder.not_found_exception.new("There is no #{sluggable_finder_options[:sluggable_type]} with #{sluggable_finder_options[:to]} '#{args.first}'")
      else
        find_without_slug(*args)
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ismasan-sluggable_finder-2.0.3 lib/sluggable_finder/finder.rb