How to create associative hashs in Ruby (on Rails) dynamicly
You should save projects in array or something like it, not hash. For example

  Mite::Customer.all.each do |customer|
    @customers[customer.id] = {:name =&gt; customer.name, :projects =&gt; []} # !!!
  end

  Mite::Project.all.each do |project|
    @customers[project.customer_id][:projects] &lt;&lt; project # !!!
  end