Collect array values

This may be more of a Ruby question, but I wasn’t sure.

Is there a way to run a find on a model and then save two fields as
key => value in an array for each row. Then use this array on the
template for checking if various checkbox or select values are
checked? I’m trying to avoid running one query to check the value for
each box in the form.

  • Kyle

Thanks Kelly, that works great.

Kyle

Kelly Dwight F. wrote:

Is this what you mean?

myhash = Hash.new
Model.find(:all).collect{|m| myhash[m.value1]=m.value2}

Is this what you mean?

myhash = Hash.new
Model.find(:all).collect{|m| myhash[m.value1]=m.value2}