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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
39025a7f572d6fe464e1fe6be399ca3b?d=identicon&s=25 Mike Dershowitz (mdersh53)
on 2007-02-16 17:17
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', {}) %><br />

and this:

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

And

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

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

Mike
873a9db33e289b558e89c039629562f5?d=identicon&s=25 James Smith (jmdjmsmith)
on 2007-02-16 17:37

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

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

-j
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-02-16 17:38
(Received via mailing list)
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
Af31e731dc3f44620a7874d9602e5bc8?d=identicon&s=25 Evan (Guest)
on 2007-02-16 18:15
(Received via mailing list)
see http://www.zenspider.com/Languages/Ruby/QuickRef.html#6 for a
lesson on string interpolations
This topic is locked and can not be replied to.