cookbook_name in recipe- TypeError: no implicit conversion of Symbol into String

戏子无情 提交于 2019-12-06 10:09:59

When you're doing + action with the strings in Ruby, it doesn't convert other types to strings. If you want from Ruby to do that automatically, you need to do interpolation like:

puts "### #{cookbook_name} :: #{recipe_name} #{Time.now.inspect} : Starting compile phase"

If you want to use + you need to provide all variables as strings:

puts "###" + cookbook_name.to_s + "::" + recipe_name.to_s + " " + Time.now.inspect + ": Starting compile phase"

I suggest you to use first method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!