# How do I insert a ruby variable into a div

**URL:** <https://www.ruby-forum.com/t/how-do-i-insert-a-ruby-variable-into-a-div/142557>\
**Category:** Rails\
**Created:** [July 9, 2008, 6:51am UTC](https://www.ruby-forum.com/t/how-do-i-insert-a-ruby-variable-into-a-div/142557 "2008-07-09T06:51:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepfunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@sheepfunk](https://www.ruby-forum.com/u/sheepfunk)\
**Post date:** [July 9, 2008, 6:51am UTC](https://www.ruby-forum.com/t/how-do-i-insert-a-ruby-variable-into-a-div/142557/1 "2008-07-09T06:51:39Z")

</div>

I want to use divs that resize based on the presence of certain ruby  
variables.

How would I insert my size variable into a div like this

\<% @width = 30 %\>

\<%=  
“\<div id=‘inner\_meal\_pan\_overview’ width=‘100%’  
style=“width:#{@width}em;”\>”  
%\>

---

<div class="post-metadata">

**Author:** ![sheepfunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@sheepfunk](https://www.ruby-forum.com/u/sheepfunk)\
**Post date:** [July 9, 2008, 10:28am UTC](https://www.ruby-forum.com/t/how-do-i-insert-a-ruby-variable-into-a-div/142557/2 "2008-07-09T10:28:07Z")

</div>

> How would I insert my size variable into a div like this
> 
> \<% @width = 30 %\>
> 
> \<%=  
> “\<div id=‘inner\_meal\_pan\_overview’ width=‘100%’  
> style=“width:#{@width}em;”\>”  
> %\>

that’s not absolutely wrong, only those slashes are not necessary  
if you use single parentheses:  
\<%= “

” %\>

or:

---

<div class="post-metadata">

**Author:** ![sheepfunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@sheepfunk](https://www.ruby-forum.com/u/sheepfunk)\
**Post date:** [July 9, 2008, 11:11am UTC](https://www.ruby-forum.com/t/how-do-i-insert-a-ruby-variable-into-a-div/142557/3 "2008-07-09T11:11:47Z")

</div>

Also \<% @width = 30 %\> should really go in the controller action
