Tag: ruby1.8

为Rails获取错误“无法分配内存”

在我的项目中,有一个脚本返回我必须在表中显示的产品列表。 要存储我使用IO.popen的脚本输入: @device_list = [] IO.popen(“device list”).each do |device| @device_list << device end device list是给我产品列表的命令。 我通过迭代将@device_list数组返回到我的视图中进行显示。 当我运行它时,我收到一个错误: Errno::ENOMEM (Cannot allocate memory): for IO.popen 我有另一个脚本device status ,只返回true和false但我得到了同样的错误: def check_status(device_id) @stat = system(“status device_id”) if @stat == true “sold” else “not sold” end end 我该怎么办?