From the issues I’ve been getting and research I did, it seems like JS integration changed in version 3.1. In particular, Rails was not able to detect the JS file at all when named create.js.rjs (I noticed that rjs was not available in list of handlers too, giving me MissingTemplate error).
Renaming it to create.js.erb fixed that issue, and some googling revealed that the JS files are essentially jQuery scripts now in 3.1. So my next attempt was to rewrite the js file from this (as appears in the book):
to this (as would make sense if written using jQuery):
Now, when adding the book to cart, the server’s response seems to imply that everything should work:
Rendered line_items/_line_item.html.erb (3.8ms) Rendered carts/_cart.html.erb (5.9ms) Rendered line_items/create.js.erb (7.6ms) Completed 200 OK in 159ms (Views: 23.1ms | ActiveRecord: 1.4ms)
However, I’m still not seeing the page update until I hit refresh. Did anyone figure out how to get this working in 3.1 or has other suggestions? I really don’t want to downgrade to 3.0.5 since there must have been a reason for this JS change, and I’d rather learn the new way than stick to the outdated one.