From: Glenn Date: 2008-08-21T03:21:31+09:00 Subject: ActiveRecord Question -- making arrays or hashs out of database tables --0-798165610-1219256309=:51363 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi,=0AI have a question about using ActiveRecord.=A0 The way I understand A= ctiveRecord is that you can use it as a kind of bridge between Ruby and a r= elational database.=A0 I believe that you can use it to create objects from= tables and that the objects are equivalent to the rows of data in the tabl= es.=0AI want to be able to use it a bit differently than that.=A0 I want to= be able to create abjects that are arrays of the values in specific fields= in a given table.=A0 For example, given the following table:=0AX=A0=A0=A0 = Y=A0=A0=A0 Z=0A1=A0=A0 'a'=A0=A0 1.1=0A2=A0=A0 'b'=A0=A0 6.2=0A3=A0=A0 'c'= =A0=A0 0.001=0AI want to be able to create an array from the X field that i= s equal to [1, 2, 3], and an array from the Y field that is equal to ['a', = 'b', 'c'], and so forth.=0A=0ABetter yet, I'd like to be able to create an = array of hashes, where each element of the array is equal to a hash of the = fields in the table, like this:=0A[{:x =3D> 1, :y =3D> 'a', :z =3D> 1.1}, {= :x =3D> 2, :y =3D> 'b', :z =3D> 6.2}, {:x =3D> 3, :y =3D> 'c', :z =3D> 0.00= 1}] =0ACan anyone tell me if this is doable in ActiveRecord, or in some oth= er Ruby package, or with some stand-alone Ruby code?=0AThanks for your help= ,=0AGlenn --0-798165610-1219256309=:51363--