# Syntax is killing me! instance var in labels

**URL:** <https://www.ruby-forum.com/t/syntax-is-killing-me-instance-var-in-labels/85828>\
**Category:** Rails\
**Created:** [February 16, 2007, 5:17pm UTC](https://www.ruby-forum.com/t/syntax-is-killing-me-instance-var-in-labels/85828 "2007-02-16T17:17:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [February 16, 2007, 5:17pm UTC](https://www.ruby-forum.com/t/syntax-is-killing-me-instance-var-in-labels/85828/1 "2007-02-16T17:17:46Z")

</div>

Hi:

I’ve got a text field tag with a value. In that value, I want to use a  
local variable. I can’t seem to get the syntax right. Here’s what I’ve  
tried:

\<%= text\_field\_tag(‘step\_1’, ‘enter Task’ @tasks ‘here’, {}) %\>

and this:

\<%= text\_field\_tag(‘step\_1’, ‘enter Task #{@tasks} here’, {}) %\>

And

\<%= text\_field\_tag(‘step\_1’, ‘enter Task @tasks here’, {}) %\>

Any help you could provide would be greatly appreciated. Thanks!

Mike

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [February 16, 2007, 5:37pm UTC](https://www.ruby-forum.com/t/syntax-is-killing-me-instance-var-in-labels/85828/2 "2007-02-16T17:37:59Z")

</div>

\<%= text\_field\_tag(‘step\_1’, “enter Task #{@tasks} here”, {}) %\>

you need to use double quotes for the string to be evaluated

-j

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [February 16, 2007, 5:38pm UTC](https://www.ruby-forum.com/t/syntax-is-killing-me-instance-var-in-labels/85828/3 "2007-02-16T17:38:33Z")

</div>

Hi Mike,

#2 should work if you replace the single quotes with double. Single  
quotes  
mean you want whatever’s inside to be treated literally. If that  
doesn’t  
fix it, it would help to see what results you’re getting.

Best regards,  
Bil

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [February 16, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/syntax-is-killing-me-instance-var-in-labels/85828/4 "2007-02-16T18:15:37Z")

</div>

see [Ruby | zenspider.com | by ryan davis](http://www.zenspider.com/Languages/Ruby/QuickRef.html#6) for a  
lesson on string interpolations
