@xdazz answer is right, but I used conditional expressions as follows
var mycount = <%= @cart.total_items %> if (mycount == 1){ $("#cart").show(2000) }
The reason I use mostly conditional statements in javascript (in the js.erb file) is because it is easy to handle
source share