I am stuck on the product change highlighting for iteration F5 (Broadcasting updates with Action Cable). I’ve tried creating a partial for the store view and using ActiveRecord::Dirty to try and compare the previous “price” value with the changed value, but I can’t seem to get it to work. Am I making this too complicated? Is there a simple solution to this? Should I be passing additional parameters in the server broadcast?
I was able to get this working, although, I’m not sure if this is the correct way to do it. I used local_assigns to set the ID of the product being updated. In the view, I compare the ID of the updated product with the ID in the loop, and if it’s equal, I use the highlighted CSS class on the DIV.
There’s always more than one way to do it, and if it works, it works :)
That said, the code in the book does get tested and to make the screenshots for this one I had to execute everything as described and it did work, so you could look at the downloadable code to see if there’s something else you were missing.
Thanks for responding David. I couldn’t find the implementation of the playtime sections in the code I downloaded. Am I missing something?