Hello there,
I have a code like.
…
items = entries.map { |entry| content_tag(“li”, mask, :id =>
“#{entry.id}”)}
…
I want to evaluate the ruby code in the string mask on the fly… it
content is:
“#{entry.name} - #{entry.state.name}/#{entry.country.name}”
I have tried “eval mask” but with no success.
thanks,
David S.
On Jul 21, 3:47 pm, David S. [email protected]
wrote:
content is:
“#{entry.name} - #{entry.state.name}/#{entry.country.name}”
I have tried “eval mask” but with no success.
Well eval is the method that evaluates code for you. In what way did
it not work ?
Fred
When I try to do:
items = entries.map { |entry| content_tag(“li”, “#{eval(mask)}”, :id =>
“#{entry.id}”)}
or
items = entries.map { |entry| content_tag(“li”, eval(mask), :id =>
“#{entry.id}”)}
I get nil as result.
David S.
Hello,
I get nil as result.
I was constructing the string in a wrong way.
The cold should look like this for the :with option:
:with => “value + ‘&search=’ + element.value + ‘&field=’ + ‘name’ +
‘&mask=’ + 'entry.name + " - " +
entry.state.name+”/"+entry.country.name’"
Regards,
David S.