循环哈希数组并执行标题化和返回数组

时间:2015-04-17 06:24:44

标签: ruby-on-rails ruby

我有一个哈希数组,我想迭代并标题化这样的元素:

  @customer_activities.each do |activity|
    activity['name'].titleize
  end

如何确保activity['name'].titleize的结果最终影响@customer_activities中的条目?

1 个答案:

答案 0 :(得分:3)

@customer_activities.each do |activity|
    activity['name'] = activity['name'].titleize
end