Sha256: b4e93faf9a4200e72f8260cacd83ac3e6cc05e10848da91f31e1e30aec1b7e17

Contents?: true

Size: 607 Bytes

Versions: 3

Compression:

Stored size: 607 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 ActiveRecord::RecordNotFound.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

3 entries across 3 versions & 1 rubygems

Version Path
ismasan-sluggable_finder-2.0.0 lib/sluggable_finder/finder.rb
ismasan-sluggable_finder-2.0.1 lib/sluggable_finder/finder.rb
ismasan-sluggable_finder-2.0.2 lib/sluggable_finder/finder.rb