Evaluating Ruby code that is in a sting, how do I do it?

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 Sousa

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.

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 Sousa