Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复Ruby代码中的这个隐式错误_Ruby_Ruby On Rails 3_Ruby On Rails 5_Chef Infra_Chef Recipe - Fatal编程技术网

如何修复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"