I need to do something like shown below; add a jquery effect depending on the value of an instance object in rails
("$('#cart').show(2000);") if @cart.total_items ==1
                <% if @cart.total_items ==1 %>
  $('#cart').show(2000);
<% end %>
                        @xdazz answer is right , but i used to use the conditional statements as follows
var mycount = <%= @cart.total_items %>
if (mycount == 1){
$("#cart").show(2000)
}
The reason i use mostly conditional statements in javascript (in js.erb file) is because this seems easy to handle 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With