【问题标题】:Ruby on Rails: NoMethodError undefined method `get_yaml' for StringRuby on Rails:字符串的 NoMethodError 未定义方法“get_yaml”
【发布时间】:2016-11-14 12:06:36
【问题描述】:

我尝试部署一个非公共项目,但有时尝试使用 报告页面(基于大虾)我有这个问题:

NoMethodError (undefined method `get_yaml' for #<String:0x7fdecffd3738>):

这段代码是:

report_content = report.draw(report_content.get_yaml)

有人知道:get_yaml 来自哪里?

谢谢。

【问题讨论】:

  • 你想用get_yaml做什么?
  • 看起来report_content 是一个字符串,它不响应get_yaml(除非某些库通过猴子补丁添加它)。 report.draw 期待什么,yaml?
  • 我找到了:def get_yaml YAML::load( @contents ) end

标签: ruby-on-rails ruby yaml prawn


【解决方案1】:

#get_yaml 方法不是标准 Ruby 库的一部分,尽管如果 yaml 库已加载,则定义了 #to_yaml。 #get_yaml(如果存在)由应用程序或应用程序正在加载的某个库定义。

【讨论】:

  • 谢谢@wayne-conrad!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多