i want to search products which are belonging to categories (saree, salwar).
i have the controller like this
class SearchController < ApplicationController def index q = params[:q] @key = q @products = Product.ransack(name_or_description_or_sku_or_category_id_in_cont: q).result(distinct: true).page(params[:page]).per(6) end end
here it is selecting name description and sku , but categoty is not searching. hoe to do it in ransack?
my model is like this
product.rb belongs_to :category
category.rb has_many :products
in my product table fields include(name,description,image,category_id,sku)
please give a solution for this
Aucun commentaire:
Enregistrer un commentaire