Variable in data path

Hi, I’m trying to pass a variable in the path to a data folder.

<% data."#{$variable}".content.each do |content| %>

Is this possible? Thank you

Yes, it’s possible, the correct syntax is to use array’s [] brackets:

<% data[variable].content.each do |content| %>

(I’m not sure why you use the $ prefix in the variable name?)

1 Like

Thank you.
The $ symbol was just to illustrate the example.

Have a nice day.