I come to you after a long while of troubleshooting and researching to
no avail. My wish is to reference a class variable whose name is
stored as a string in another variable. I will try to set up an
example:
variable_name = 'text'
print @#{variable_name}
I think that is how it would work, and i think the syntax is nearly
correct, but... its not.
I come to you after a long while of troubleshooting and researching to
no avail. My wish is to reference a class variable whose name is
stored as a string in another variable. I will try to set up an
example:
variable_name = 'text'
print @#{variable_name}
I think that is how it would work, and i think the syntax is nearly
correct, but... its not.
Any help? Thanks alot guys!
Not quite the same, but let's say you have an AR model named Foo that has an attribute named bar, then:
myfoo = Foo.find(:first)
myfoo.send('bar') # same as myfoo.bar