small medium large xlarge

Generic-user-small
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 %>

</code>

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

</code>

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 ?

Generic-user-small
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