我以数组形式输出如下:
{:compartmentId=>"osdaa", :displayName=>"server1", :id=>"dffdssa",
:lifecycleState=>"AVAILABLE", :sizeInGBs=>50, :sizeInMBs=>1024,
:timeCreated=>#<DateTime: 2017-09-18T05:57:43+00:00 ((2458015j,21463s,494000000n),+0s,2299161j)>,
:timeRequestReceived=>#<DateTime: 2017-09-18T05:57:37+00:00 ((2458015j,21457s,331000000n),+0s,2299161j)>,
:uniqueSizeInGBs=>XX, :uniqueSizeInMbs=>14072, :volumeId=>"abcd"},
{:compartmentId=>"osdaa", :displayName=>"server1", :id=>"dffdssa",
:lifecycleState=>"AVAILABLE", :sizeInGBs=>50, :sizeInMBs=>1024,
:timeCreated=>#<DateTime: 2017-09-18T05:57:43+00:00 ((2458015j,21463s,494000000n),+0s,2299161j)>,
:timeRequestReceived=>#<DateTime: 2017-09-18T05:57:37+00:00 ((2458015j,21457s,331000000n),+0s,2299161j)>,
:uniqueSizeInGBs=>XX, :uniqueSizeInMbs=>14072, :volumeId=>"abcd"},
{:compartmentId=>"osdaa", :displayName=>"server1", :id=>"dffdssa",
:lifecycleState=>"AVAILABLE", :sizeInGBs=>50, :sizeInMBs=>1024,
:timeCreated=>#<DateTime: 2017-09-18T05:57:43+00:00 ((2458015j,21463s,494000000n),+0s,2299161j)>,
:timeRequestReceived=>#<DateTime: 2017-09-18T05:57:37+00:00 ((2458015j,21457s,331000000n),+0s,2299161j)>,
:uniqueSizeInGBs=>XX, :uniqueSizeInMbs=>14072, :volumeId=>"abcd"}
我正在尝试获取id的值。 我的代码是
ids = bkp_id.map { |x| x[:id] }
puts ids
end
获得以下错误:
list_att_vol.rb:31:in `block in <class:List_volume_attached_XXX>': undefined method `[]' for #<OCI::Core::Models::IScsiVolumeAttachment:0x0000000001356a50> (NoMethodError)
from list_att_vol.rb:31:in `map'
from list_att_vol.rb:31:in `<class:List_volume_attached_XXX>'
from list_att_vol.rb:4:in `<main>'
请告诉我们如何从数组输出中检索id的值?
答案 0 :(得分:0)
看看是否有效:
<script src="/static/js/main.js?cb={{ build_date_utc.strftime('%S%f') }}">