从ActiveRecord :: Base.connection.execute的结果中删除列名

时间:2014-12-27 07:19:03

标签: ruby-on-rails activerecord

我收到了列名的回复,但我不需要它。如何在没有列名的情况下获得响应。

那就是我不需要钥匙:时间,高,低,......

我只需要结果值。

我得到ActiveRecord::Base.connection.execute(q_cmd)

的结果
{"time"=>"2014-01-02 01:14:00", "high"=>"2360", "low"=>"2360", "open"=>"2360", "close"=>"2360", "volume"=>"9"}{"time"=>"2014-01-02 01:14:01", "high"=>"0", "low"=>"0", "open"=>"0", "close"=>"0", "volume"=>"0"}{"time"=>"2014-01-02 01:14:02", "high"=>"0", "low"=>"0", "open"=>"0", "close"=>"0", "volume"=>"0"}{"time"=>"2014-01-02 01:14:03", "high"=>"0", "low"=>"0", "open"=>"0", "close"=>"0", "volume"=>"0"}{"time"=>"2014-01-02 01:14:04", "high"=>"0", "low"=>"0", "open"=>"0", "close"=>"0", "volume"=>"0"}

1 个答案:

答案 0 :(得分:0)

结果为Hash,您可以在其上调用values

res = ActiveRecord::Base.connection.execute(q_cmd)
res.values

这将只给出数组中的值!

参考文档:Hash#values