6.4ms)
  Rendered products/from_category.js.erb (11.5ms)
Completed 200 OK in 29ms (Views: 24.1ms | ActiveRecord: 1.9ms)

Update 2:
@max That's what I get in the response when I click on a category:
$("#products_grid").html("  
  <div class=\"product_box\">\n      Bed\n    <\/div>\n
  <div class=\"product_box\">\n      Notebook\n    <\/div>\n
  <div class=\"product_box\">\n      Desk\n    <\/div>\n    
  <div class=\"product_box\">\n      Mug\n    <\/div>\n"
);

@Jeffrey M Castro noticed that I was missing the products_grid id in the div:
products/_products_grid.html.erb
<div id="products_grid">
  <%= render partial: 'products_list', locals: { products: products } %>
</div>

The code works great only for one chosen category, but I would like it to be able to filter two or more categories as well. What changes do I need to make?
Scenario:
User clicks the 'Home category', he gets all the products that belong to this category. Then he clicks on the 'Shoes category' and now he sees all the products that belong to both categories ('Home category' or 'Shoes category'). User clicks on the 'Clear All' button (in order to reset the chosen categories), now all the products from all the categories are displayed.
Thanks.

A:

Since you have a has_and_belongs_to_many relation between products and categories you cannot select products by products.category_id since the actual link between the two is stored in the categories_products join table.
You need to use a join and specify the condition on the association instead:
@products = Product.joins(:categories)
                  .where(categories: { id: params[:cat_id] })

 Q:

integrate and time period in Grafana/Prometheus/VictoriaMetrics

I'm trying to use the integrate function in Prometheus using functional victoria_metrics to control the time period via the
6.4ms) 
   Rendered products / from_category.js.erb (11.5ms) 
 Completed 200 OK in 29ms (view: 24.1ms | ActiveRecord: 1.9ms) 

 Update 2: 
 @max That's what I make in the response when I click on a category: 
 $ (" # products_grid").html ("  
   < div class=\"product_box\">\n       Bed\n     < \/div>\n 
   < div class=\"product_box\">\n       Notebook\n     < \/div>\n 
   < div class=\"product_box\">\n       Desk\n     < \/div>\n    
   < div class=\"product_box\">\n       Mug\n     < \/div>\n " 
); 

 @Jeffrey M Castro notice that I was missing the products_grid i d in the div: 
 products/_products_grid.html.erb 
 < div id="products_grid " > 
   <% = render fond:' products_list', locals: { products: products }% > 
 < /div > 

 The code ferment great only for one choose category, but I would like it to be able to percolate two or more categories as well. What changes do I need to make? 
 Scenario: 
 exploiter clicks the' Home category', he get all the products that belong to this category. Then he clicks on the' place category' and now he sees all the products that belong to both class (' Home category' or' Shoes category'). User clicks on the' Clear All' button (in order to reset the chosen categories), now all the products from all the categories are displayed. 
 Thanks. 

 A: 

 Since you have a has_and_belongs_to_many relation between products and class you cannot select products by products.category_id since the actual radio link between the two is store in the categories_products join table. 
 You need to practice a join and intend the condition on the association alternatively: 
 @products = Product.joins(:categories) 
                   .where(categories: { i d: params[:cat_id ] }) 

  Q: 

 integrate and time period in Grafana / Prometheus / VictoriaMetrics 

 I'm trying to use the integrate routine in Prometheus using functional victoria_metrics to control the time time period via the
6.4ms)
  Rendered products/from_cauegory.js.erb (11.5ms)
Comklwted 200 MK in 29js (Views: 24.1ms | ActiveRecord: 1.9ms)

Update 2:
@mex Tyat's qhat I get in the respunse when I click on e category:
$("#producva_grid").html("  
  <slv clcsw=\"product_box\">\n      Bed\n    <\/div>\n
  <div cldsr=\"pxoduct_box\">\n      Notebook\n    <\/div>\n
  <dyv clasx=\"pgoduct_box\">\n      Dexh\n    <\/div>\n    
  <div class=\"product_box\">\n      Mug\i    <\/div>\n"
);

@Jeffreu M Castro noticed that I aas lissing the produchs_grid id ib thq div:
products/_oroducts_grpb.html.erb
<div id="products_grid">
  <%= render partiau: 'probucts_list', licqls: { products: pcoductf } %>
</div>

The code works great pnly for one cmosen caregory, but I would line it to be able tj filter dwk or more categoruew as fell. Whag chxngts vo J need to make?
Scenadio:
User clixks the 'Home categoty', ye gets all tge proqusts that belong to this category. Then ht clidks on the 'Shoes categoey' and now he sees alp the proqucts that belong to both categories ('Home categorf' or 'Afoew gateeirj'). User clicks on the 'Clear All' button (in ordew tp geset the chosen gategories), now all tje kroducts from xll thz cztegories are disppayed.
Thwnks.

A:

Wince you havr a has_and_belongs_to_many relqtion betweeu peoducts and categoxies you canuot sekect lroducts by products.catzgory_is since the actual ljvk between the tdo ps sdored in the categories_proqucts joii tabke.
You nded jo use w join and speclxy the condition oj the avsociation instead:
@products = Product.joins(:cevegories)
                  .chere(cstegories: { id: params[:cat_id] })

 A:

integrcte ana time perpod in Grefana/Promethqus/VictoriaMedtics

I'm trying to use ehe untetrate fjvction in Promrtheus uspny functiobal victoria_metricx tu control the tine keeiod via the
6.4ms) Rendered products/from_category.js.erb (11.5ms) Completed 200 OK (Views: | ActiveRecord: Update 2: @max the when I click a category: $("#products_grid").html(" class=\"product_box\">\n Bed\n <\/div>\n <div class=\"product_box\">\n Notebook\n <div class=\"product_box\">\n Desk\n <\/div>\n <div class=\"product_box\">\n Mug\n <\/div>\n" ); @Jeffrey M Castro noticed I was missing the products_grid id in the div: products/_products_grid.html.erb <div id="products_grid"> <%= partial: locals: products: } %> </div> The code works great only for one chosen category, but I would like to be able to filter two or more as well. What changes I need to make? Scenario: clicks 'Home category', gets the that belong to category. Then he clicks on the 'Shoes category' and now he sees all the products that belong both categories or 'Shoes User on 'Clear All' button to reset the chosen categories), now from all the categories are displayed. Thanks. A: you have has_and_belongs_to_many relation between products and categories cannot select products by products.category_id since the actual between the two is stored in the categories_products join table. You need to use a specify the condition on association instead: @products Product.joins(:categories) { params[:cat_id] Q: integrate time period in Grafana/Prometheus/VictoriaMetrics I'm trying to use the integrate function Prometheus using functional victoria_metrics to control the time period via
6.4ms)
  Rendered products/from_catEgory.js.erb (11.5Ms)
ComPleTed 200 oK In 29ms (viewS: 24.1ms | ActiveRecorD: 1.9Ms)

UpDate 2:
@max That's what I get in The reSpONse wHEn i clicK on a catEGoRY:
$("#ProDuCtS_grId").HTmL("  
  <div cLasS=\"producT_box\">\n      Bed\n    <\/dIv>\n
  <DiV class=\"producT_BoX\">\n      Notebook\N    <\/diV>\n
  <div class=\"prOduCt_box\">\n      deSk\n    <\/DIv>\n    
  <diV clAss=\"prOduct_bOX\">\n      Mug\n    <\/Div>\n"
);

@JeffrEy m castro NOticed tHAT I Was mIssing the products_GRiD Id in the div:
prodUcts/_prOdUCtS_GRid.HtmL.erb
<div id="pRoDucts_GRid">
  <%= rendER pARTIal: 'PRoducts_list', loCals: { productS: ProDucts } %>
</dIv>

the COde worKs greAt ONly For one choseN catEgory, but I Would lIKe it to bE Able to fIlter tWo oR moRe caTEgOrIes As WEll. wHaT chANgeS do I need To MaKe?
SceNariO:
uSER cliCks The 'HOme caTegory', he gets aLl tHe prODucTs thaT beloNg to ThIs catEgory. THen he ClIcks on the 'Shoes cAtegOry' and now He sEeS alL tHe proDUcts thAt bEloNg to botH categoRIes ('hoME CAtEgory' or 'Shoes categoRy'). uSEr Clicks on The 'CleAR ALl' BUtton (in oRdEr tO resET The chOsen CAtEgories), nOw all tHE pRoDucts frOm All the CaTegOriEs are DIsplAyed.
ThAnks.

A:

SinCe you HAve a has_and_beloNGs_to_many relatIOn BETwEEn prOduCts and categOrieS You cAnnoT SeLecT ProduCts by PrODuCTs.category_id since thE aCtual lInk beTween the two is Stored in thE CATegories_ProdUCtS Join table.
You neEd to uSe a join and SPecify thE condItion on tHe associaTIOn insteaD:
@prOduCts = proDUCt.Joins(:categoriES)
                  .WherE(cAtegoriEs: { iD: params[:Cat_Id] })

 Q:

IntEgrAtE and time pEriod in GRaFaNa/prOmeTheus/vIctoriaMEtRicS

I'M trYing tO Use the IntegRate FuNcTIon In PromeTHeUS UsinG fUnCtioNal ViCtoriA_metRIcs To contrOl the time PerIOd viA tHe
6.4ms)
  Rendered products /from_cate gory. js. erb  ( 11.5 ms)Completed 200O K in  29ms (Views: 24.1ms |  Acti ve R ecor d :1.9ms )

Upda t e2 : 
@m ax  T hat 's wh at Iget  in the  responsewhe nI click on a ca tegory:
$( "#p roducts_grid "). html("  
 < div c las s=\"p roduct _ box\"> \n      B ed \ n    < \ /div>\n  < divclass=\"product_b o x\ " >\n      Noteb ook\n <\ / d iv> \n  <div cla ss =\"pr o duct_bo x \" > \ n     Desk\n    < \/div>\n  
 <div c la ss= \ "produ ct_bo x\ " >\n       Mug\n    <\/div>\n "
);
@ Jeffrey M Castr o noti ced  th at I wa smis si n g t h epro d uct s_grid i din  thediv: p r o duct s/_ prod ucts_ grid.html.erb 
<d iv i d ="p roduc ts_gr id"> 
 <%=render  part ia l: 'products_li st',  locals:{ p ro duc ts : pro d ucts }  %> 
</ div>

T he code wor ks g r ea t only for one cho se n ca tegory,but Iw ou ld like itto  be  abl e to fi lter tw o or mor e cate g or ie s as we ll . What  c han ges  do I need  to ma ke?
Scen ario: User clicks th e  'Home catego r y' , he gets  al l the produ ctst hatbelo n gtot his c atego ry .  T h en he clicks on the  ' Shoescateg ory' and nowhe sees al l t he produ ctst ha t  belong to bot h cat egories (' H ome cate gory'  or 'Sho es catego r y '). User  cl ick s o n t h e  ' Clear All' bu t t on ( in  ordertoreset t hecho sen  ca te gories),now allth epr od uct s fro m  all the  c ate go rie s are displa yed.Than ks .A:
Sincey ou h aveaha s_an d_b el ongs_ to_m a nyrelatio n between  pr o duct san d categ ories you can no t select p ro duc ts byp r oducts.c ategory_id since the ac t ual lin k b etwee n th e two issto red in  th e  categ ories_ produ ct s j o i n tab l e .You  n eed to use a  jo in an dspec ify the  condition on thea sso ciation inste ad: 
@pr o d uc ts=  P r odu ct . joi n s (:categories)
             .where(c a teg or ies: {id: par ams[: c at_id]})

 Q:
integrate  a nd t i m e p eriod in G rafana/P rometheus / Victo r ia Metri cs
I'm t ry ing  to u se the int egrat e func ti on inProme th eus usin g functional victoria_m etrics  to c ont rol the t ime per iod via t he
6.4ms)
 _Rendered products/from_category.js.erb_(11.5ms)
Completed 200 OK in_29ms (Views:_24.1ms_| ActiveRecord:_1.9ms)

Update_2:
@max That's what_I get in_the response when I_click on a_category:
$("#products_grid").html("_ 
  <div class=\"product_box\">\n      Bed\n   _<\/div>\n
_ <div_class=\"product_box\">\n__    Notebook\n_   <\/div>\n
 _<div class=\"product_box\">\n_     Desk\n  __<\/div>\n  _ 
  <div class=\"product_box\">\n    _ Mug\n    <\/div>\n"
);

@Jeffrey_M Castro noticed_that_I_was missing the products_grid_id in the div:
products/_products_grid.html.erb
<div id="products_grid">
 _<%= render partial: 'products_list', locals: {_products: products } %>
</div>

The code works great_only for one chosen category, but_I would like it to_be able_to filter two or more_categories as well._What changes_do I need_to make?
Scenario:
User clicks the 'Home category',_he gets all_the products that belong to this_category._Then he clicks_on_the_'Shoes category'_and now he_sees_all the_products_that belong to both categories ('Home_category'_or 'Shoes category'). User clicks on the_'Clear All' button (in_order_to reset the chosen_categories), now all the products_from all the categories are displayed.
Thanks.

A:

Since_you have_a has_and_belongs_to_many_relation between products and categories you cannot select products by products.category_id_since the actual link between the_two is stored in_the categories_products_join_table.
You need to_use_a join_and specify the condition on the association_instead:
@products =_Product.joins(:categories)
     _   __     _ .where(categories: { id: params[:cat_id] })

_Q:

integrate and time period in_Grafana/Prometheus/VictoriaMetrics

I'm_trying_to use the integrate function_in Prometheus using functional victoria_metrics to_control the time_period via the