Syntax is killing me! instance var in labels


#1

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


#2

<%= text_field_tag(‘step_1’, “enter Task #{@tasks} here”, {}) %>

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

-j


#3

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


#4

see http://www.zenspider.com/Languages/Ruby/QuickRef.html#6 for a
lesson on string interpolations