我对rails数组有一个简单的问题。
代码如下:
app/models/employee.rb
s={}
EmployeeDepartment.all.each{|employee_department|
s[employee_department.name] = where(:employee_department_id => employee_department.id).count(:employee_department_id)
#Employee.total_on(employee_department.id)
}
return s.to_a
示例输出:
[["First dept", 10], ["Second dept", 12]]
但我需要这样的输出,如下:
[['First dept', 10], ['Second dept', 12]] or [[First dept, 10], [Second dept, 12]]
有可能吗?