From: Louis J Scoras Date: 2006-06-23T04:05:02+09:00 Subject: Re: Turning an Array into a Hash based on an attribute value On 6/22/06, Ashley Moran wrote: > data_items = DataItem.find(:all) > # data_items[3].identifier => "my_identifier" > data_items[:my_identifier].do_something # => data_items[3].do_something I think your implementation of this looks pretty reasonable, but the above begs the question, why does he want to do this? One would think that you'd be better off just asking ActiveRecord for the correct object, no? I'm not sure of the api--i.e.: this is untested--but why not something like this: particular_item = DataItem.find_by_identifer("my_identifier") particular_item.do_something This is the sort of thing that databases are good at. -- Lou.