Forum: Ruby Retreiving column values from a variable column name

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.
Chris (Guest)
on 2006-05-26 03:26
I need to retrieve a value from a column which I reference from a
string, I cannot hardcode in the column name.

I would like something like this

 text = shape.colour

however I am going to loop through a number of columns and the column
specified after the (.) will be a variable or string.

for p in particulars
  text = shape.p
end

I've seen you can use #{some_string}, what exactly does this do to a
string?

Thanks in advance
This topic is locked and can not be replied to.