small medium large xlarge

13 Nov 2011, 11:53
Colin (2 posts)

I am using the last edition of agile ruby. I have a problem when I reload the store index the cart is not rendred when I use the hidden_div_if code

<% hidden_div_if(@cart.line_items.empty?, id: 'cart') do %>
  <%= render @cart %>
<% end %>


def hidden_div_if(condition, attributes = {}, &block 
  if condition
    attributes["style"] = "display: none"
  content_tag("div", attributes, &block)


I triple-checked my code but the I don’t see what’s going wrong, when I activate hidden_div in my code the div “cart” remains empty

Any idea ?

22 Nov 2011, 13:46
Taylor Mock (5 posts)

hopefully you found it by now, but if not. look at the start of your hidden div. missing ‘=’. you have <% should be <%= hidden_div_if………

You must be logged in to comment