2
我有一個廚師資源的以下屬性:廚師LWRP的屬性方法是什麼?我可以通過哪些方法?
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
所以我想attribute
S IN的資源文件只是方法是接受參數數組並通過[..args ..]它是一回事。爲什麼這不起作用?我想我對這種情況下的ruby對象屬性類型以及它們的行爲是什麼感到困惑。
除非你是一個真正的老版本的廚師,請使用'property'而不是'attribute'。後者僅適用於向後兼容。 – coderanger