Get column value of col1 .. col10

Hi,

I have a table with column name like col1, col2, col3, col4 … col10.
In rails, after I get the instance of the class, I would like to use a
for loop to retrieve values from these columns and put them into a hash.
The hash will be used for another find call. Is that possible?

Thanks.

Arnold

Arnold wrote:

Hi,

I have a table with column name like col1, col2, col3, col4 … col10.
In rails, after I get the instance of the class, I would like to use a
for loop to retrieve values from these columns and put them into a hash.
The hash will be used for another find call. Is that possible?

Thanks.

Arnold

So do you want to basically copy just the part of the hash represented
by col1…col10?

Here’s a start (not tested)

new_hash = {};
(1…10).each do |x|
colname = “col#{x}”
new_hash[colname] = @orig_AR_object.send(colname)
end

Wes