如何修复Ruby代码中的这个隐式错误
在这一行中,我遇到了错误如何修复Ruby代码中的这个隐式错误,ruby,ruby-on-rails-3,ruby-on-rails-5,chef-infra,chef-recipe,Ruby,Ruby On Rails 3,Ruby On Rails 5,Chef Infra,Chef Recipe,在这一行中,我遇到了错误 node.default['aem_dispatcher_cookbook']['ip_address'] = nodes.first('ipaddress').to_i 获取此错误 Recipe Compile Error in /root/.chef/local-mode-cache/cache/cookbooks/aem_dispatcher_cookbook/recipes/default.rb ==============================
node.default['aem_dispatcher_cookbook']['ip_address'] = nodes.first('ipaddress').to_i
获取此错误
Recipe Compile Error in /root/.chef/local-mode-cache/cache/cookbooks/aem_dispatcher_cookbook/recipes/default.rb
================================================================================
TypeError --------- no implicit conversion of String into Integer
如果我将
.to_I
删除,则会得到相同的结果。您的数据的一层可能具有数组,但您希望将其作为哈希
见示例:
hash = { foo: [{ bar: "baz" }]}
=> hash[:foo][:bar]
TypeError: no implicit conversion of Symbol into Integer
实际上,我正在尝试在chef code
publish\u vm='apvrp27560'nodes=search(:node,'hostname:publish\u vm')节点中获取其他系统的ip地址。默认值['aem\u dispatcher\u cookbook']['ip\u address']=nodes。首先('ipaddress')
这是我的代码,我尝试过你的方法,但没有得到。你能检查一下吗
hash = { foo: [{ bar: "baz" }]}
=> hash[:foo].first[:bar]
"baz"