# File lib/acts_as_suggest.rb, line 47
        def suggest(fields, word, treshold = nil)
          similar_results = []
          # Define treshold if not explicitly specified
          unless treshold
            if word.size <= 4
              treshold = 1
            else
              # Longer words should have more tolerance
              treshold = word.size/3
            end
          end
          
          # Checks if an array of fields is passed
          if fields.kind_of?(Array) 
            conditions = ""
            # Hash that will contain the values for the matching symbol keys
            param_hash = {}
            # Builds the conditions for the find method
            # and fills the hash for the named parameters
            fields.each_with_index do |field, i|
              param_hash[field] = word
              if fields.size > 1 && i < fields.size - 1
                conditions += "#{field} = :#{field} OR " 
              else
                conditions += "#{field} = :#{field}"
              end
            end
            # Search multiple fields through named bind variables 
            # (for safety against tainted data)
            search_results = self.find(:all, :conditions => [conditions, param_hash])
          else
            # Only one field to search in
            search_results = self.find(:all, :conditions => ["#{fields} = ?", word])
          end
       
          # Checks if +word+ exist in the requested field(s)
          if search_results.empty?
            # Retrieves list of all existing values in the table
            all_results = self.find(:all)                     
            # Checks if the table is empty
            unless all_results.empty?
              all_results.each do |record|
                if fields.kind_of?(Array)
                  # Adds all the strings that are similar to the one passed as a parameter (searching in the specified fields)
                  fields.each {|field| similar_results << record.send(field).to_s if record.send(field).to_s.similar?(word, treshold)}
                else
                  # Adds all the strings that are similar to the one passed as a parameter (searching the single field specified only)
                  similar_results << record.send(fields).to_s if record.send(fields).to_s.similar?(word, treshold)
                end
              end
            end
            # Remove multiple entries of the same string from the results
            return similar_results.uniq
          else
            # The value exists in the table,
            # the corrisponding records are therefore returned in an array
            return search_results
          end
          
        end