Sha256: 9f6f2f44d2a9e0bf96d3f93955b978fe7d1f6328d1f13ce06423652057021c48
Contents?: true
Size: 778 Bytes
Versions: 2
Compression:
Stored size: 778 Bytes
Contents
class FacetedSearch::KeywordFacet < FacetedSearch::Facet # Scope for like text on specified attributes def initialize(attributes, table_name, session) @attributes = attributes @table_name = table_name @session = session end def refined(scope) if not search_phrase.blank? for word in search_phrase.split sql = @attributes.map {|a| "#{@table_name}.#{a} like ?"}.join(" or ") values = ["%#{word}%"]*@attributes.length scope = scope.scoped :conditions=>[sql,values].flatten end end return scope end def param_name() "#{@table_name}_keyword" end def search_phrase @session[param_name] end def parameter_names [param_name] end def form "HTML HERE ??!?" end end
Version data entries
2 entries across 2 versions & 1 rubygems