【问题标题】:Undefined method `children' for nil:NilClass since the update to Haml 3.1自更新到 Haml 3.1 以来,nil:NilClass 的未定义方法 `children'
【发布时间】:2011-08-22 10:48:27
【问题描述】:

背景资料

我正在通过Crafting Rails 工作,在第 4 章中,我为“merb”模板制作了一个处理程序——穿插 erb 的降价。这可以编译成文本或 html,因此非常适合邮件。我的“new_submission”通知电子邮件在 app/views/notifications/new_submission.merb 中有一个模板。然后在 app/mailers/notifications.rb 中,你需要做的就是

mail(:to => Person.editor.email) do |format|
  format.text
  format.html
end

单个 .merb 模板被编译为多部分电子邮件的文本和 html 部分。呜呼!您可以在an excerpt from Crafting Rails 中阅读更多相关信息,也可以浏览my specific implementation of it

某处,不知何故,出了点问题

我大约一周前更新了我的 Gemfile,并认为我的一切正常,因为我的页面正在加载并且 Compass 和 Sass 不再抱怨我。由于某些可怕的原因,我没有进行任何测试。但事实证明,从那时起,每当我调用尝试发送此 new_submission 电子邮件的操作(例如“packlet.destroy”)时,我都会收到此错误:

ActionView::Template::Error (undefined method `children' for nil:NilClass):
  app/mailers/notifications.rb:25:in `block in new_submission'
  app/mailers/notifications.rb:23:in `new_submission'
  app/models/submission.rb:62:in `has_been'
  app/models/packlet.rb:20:in `destroy'
  app/controllers/packlets_controller.rb:27:in `destroy'

app/mailers/notifications 的第 26 行是“format.html”行,如上所示。

我通过更精细地执行此捆绑更新,已将其缩小为 haml/sass 3.1 的问题。我更新了 Rails,运行了我的测试,没有问题。我更新了haml,运行了我的测试,结果出现在四个地方。

任何指导将不胜感激。

【问题讨论】:

    标签: ruby-on-rails haml actionmailer sass handlers


    【解决方案1】:

    这是 Haml 3.1 中的一个已知问题,由 cmets 中的嵌套内容引起。 (我学到了这个from haml's creator himself。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      • 2011-07-27
      • 2013-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多