Search form with acts_as_taggable_on (Rails 3) -
i have searchbox search products. each product has title , tagged multiple tags.
i want able search products title or tag. in other words if have product called "green tea" , product tagged "green, red, blue" , type "green" searchbox, i'd both products appear in search results.
i using rails 3, acts_as_taggable_on, ruby 1.9.2.
in controller, action displays search results (where :q query string search box):
def results @products = product.where("title ?", "%#{params[:q]}%") \ | product.tagged_with("%#{params[:q]}%") end
Comments
Post a Comment