From: Daniel N Date: 2006-09-26T07:35:34+09:00 Subject: Re: ruby wizards, help me beautify skanky code ------=_Part_35663_32148394.1159223730768 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/26/06, dblack@wobblini.net wrote: > > Hi -- > > > You can also do away with isolating the keys and then using them to > dig out the values -- just give yourself both: > > Interaction.find(:all).group_by(&:involvement_type).each do |key,value| > instance_variable_set("@#{key.downcase.pluralize}", > value.map {|i| i.drug.name }.to_set) > end > > (I'm not sold on to_set instead of uniq, but either should be OK.) I didn't realise you could get the key and value from the each method. Thats a good one to know. ------=_Part_35663_32148394.1159223730768--