app/controllers/client_controller.rb
def products
    if params[:category_id]
      @parent_categories = Category.where(id: params[:category_id])
      @products = Category.find(params[:category_id]).products_of_children
    else
      @parent_categories = Category.where(parent_id: nil)
      @products = Product.all
    end
  end
#client/products: products page
client/products: products page
client / products : products page
def products
    if params[:category_id]
      @parent_categories = Category.where(id: params[:category_id])
      @products = Category.find(params[:category_id]).products_of_children
    else
      @parent_categories = Category.where(parent_id: nil)
      @products = Product.all
    end
  end
def products if params [ :category_id ] @parent_categories = Category . where ( id : params [ :category_id ] ) @products = Category . find ( params [ :category_id ] ) . products_of_children else @parent_categories = Category . where ( parent_id : nil ) @products = Product . all end end
client/products: products page
client / products : products page