My product_controller
class ProductController < ApplicationController
def index
@product = Product.all
@categories = Category.all
end
def from_category
@product = Product.joins(:category).where(category: { id: params[:cat_id] })
respond_to do |format|
format.js
end
end
end
My form_category.js.erb
$("#products_grid").html("<%= escape_javascript(render partial: 'product/products_list', locals: { product: @selected } ) %>");
I want to filter products by categories and found this way, but I get an error on this part