Topic: Is their anyway to make this model search condition search for partia

Is their anyway to make this model search condition search for  partial "not the view file" searches?
Like right now it is demanding that a search be the entire word or value , in stead of partials like I spell write the word fish and it returns anything that had fish in it's filter coulm..

At least a small explaination on how it's working would be nice big_smile


class Product < ActiveRecord::Base
  def self.find_filtered(keyword, filters = {})
    conditions = []
    column_names.each do |column|
      conditions << "#{column} = #{sanitize(keyword)}" unless filters[column].blank?
    end
    find(:all, :conditions => conditions.join(' or '))
  end
end

please and thank you

Re: Is their anyway to make this model search condition search for partia

If you use the word LIKE instead of an equal sign, and put a percent sign before and after the keyword, it will do a partial search. Like so:

conditions << "#{column} = #{sanitize('%' + keyword.to_s + '%')}" unless filters[column].blank?

Railscasts - Free Ruby on Rails Screencasts

Re: Is their anyway to make this model search condition search for partia

awesome! .... many many many thanks.. you should write a book !