# Question about method "hidden\_div\_if" in AWDR 2

**URL:** <https://www.ruby-forum.com/t/question-about-method-hidden-div-if-in-awdr-2/142978>\
**Category:** Rails\
**Created:** [July 14, 2008, 5:52am UTC](https://www.ruby-forum.com/t/question-about-method-hidden-div-if-in-awdr-2/142978 "2008-07-14T05:52:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flychunjae](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3ab097/32.png) [@flychunjae](https://www.ruby-forum.com/u/flychunjae)\
**Post date:** [July 14, 2008, 5:52am UTC](https://www.ruby-forum.com/t/question-about-method-hidden-div-if-in-awdr-2/142978/1 "2008-07-14T05:52:24Z")

</div>

I followed the sample code in AWDR 2 like this:

store\_helper.rb

def hidden\_div\_if(conditions, attributes = {})  
if conditions  
attributes[“style”] = “display:none”  
else  
attr = tag\_options(attributes.stringify\_keys)  
“\<div #{attr}\>”  
end  
end

store.html.erb

\<%= hidden\_div\_if(@cart.items.empty?, :id =\> “cart”) %\>  
\<%= render(:partial =\> “cart”, :object =\> @cart) %\>

when the cart is empty, the “

” snippet is not  
displayed there.

could anybody help me with this?

---

<div class="post-metadata">

**Author:** ![flychunjae](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3ab097/32.png) [@flychunjae](https://www.ruby-forum.com/u/flychunjae)\
**Post date:** [July 14, 2008, 6:05am UTC](https://www.ruby-forum.com/t/question-about-method-hidden-div-if-in-awdr-2/142978/2 "2008-07-14T06:05:53Z")

</div>

sorry for the mistake, I didn’t read the sample code carefully.

there’s no “if…else…end” structure in this method. 🙂

> store\_helper.rb
> 
> def hidden\_div\_if(conditions, attributes = {})  
> if conditions  
> attributes[“style”] = “display:none”  
> else  
> attr = tag\_options(attributes.stringify\_keys)  
> “\<div #{attr}\>”  
> end  
> end
