【发布时间】:2017-02-10 07:31:06
【问题描述】:
我在厨师资源中有以下属性:
attribute :attribName, kind_of: String, name_attribute: true, default: 'big string sldkjslkdflksdksdlkff'
我想打破它,让它看起来不错,所以我这样做了:
attribute [
:attribName,
kind_of: String,
name_attribute: true,
default: 'big string sldkjslkdflksdksdlkff'
]
但在收敛时出现错误:
NoMethodError
-------------
undefined method `to_sym' for #<Array:0x00000004a63b60>
Did you mean? to_s
to_yaml
to_set
Platform:
---------
x64-mingw32
Running handlers:
[2016-10-01T19:07:39-07:00] ERROR: Running exception handlers
Running handlers complete
[2016-10-01T19:07:39-07:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 11 seconds
[2016-10-01T19:07:39-07:00] FATAL: Stacktrace dumped to C:/Users/ADMINI~1/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
[2016-10-01T19:07:39-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-10-01T19:07:39-07:00] FATAL: NoMethodError: undefined method `to_sym' for #<Array:0x00000004a63b60>
Did you mean? to_s
to_yaml
to_set
所以我认为资源文件中的attributes 只是接受参数数组并将 [..args..] 传递给它的方法。为什么这不起作用?我想我对这种上下文中的 ruby 对象属性的类型以及它们的行为感到困惑。
【问题讨论】:
标签: ruby chef-infra chef-recipe cookbook lwrp