Forum: Ruby on Rails Syntax is killing me! instance var in labels....

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mike D. (Guest)
on 2007-02-16 18:17

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

<%= text_field_tag('step_1', 'enter Task' @tasks 'here', {}) %><br />

and this:

<%= text_field_tag('step_1', 'enter Task #{@tasks} here', {}) %><br />


<%= text_field_tag('step_1', 'enter Task @tasks here', {}) %><br />

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

James S. (Guest)
on 2007-02-16 18:37

<%= text_field_tag('step_1', "enter Task #{@tasks} here", {}) %>

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

Bill W. (Guest)
on 2007-02-16 18:38
(Received via mailing list)
Hi Mike,

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

Best regards,
Evan (Guest)
on 2007-02-16 19:15
(Received via mailing list)
see for a
lesson on string interpolations
This topic is locked and can not be replied to.