class MyModel
def self.find_entries(params)
fields = [:prefix, :two_letter, :three_letter]
conditions = fields.inject([[]]) do |where, field|
unless params[field].blank?
where.first << "#{field} LIKE ?"
where << "%#{params[field]}%"
end
where
end
if conditions.first.empty?
[]
else
conditions[0] = conditions.first.join(" AND ")
paginate :conditions => conditions,
:page => params[:page], :per_page => 10
end
end
end