未定义的方法“children”自更新到 Haml 3.1 以来 nil:NilClass
背景信息
我正在通过 Crafting Rails 进行工作,在第 4 章中我做了一个“merb”模板的处理程序——散布着 erb 的 markdown。它可以编译成文本或 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 部分中。呜呼!您可以在Crafting Rails 摘录中阅读更多相关内容,并且您可以浏览围绕我的具体实现。
不知何故,某个地方出了问题
,大约一周前我更新了 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,运行了测试,这在四个地方弹出。
任何指导将不胜感激。
Background info
I am working my way through Crafting Rails and in Chapter 4 I made a handler for "merb" templates—markdown with erb interspersed. This can be compiled into text or html, so it's perfect for mail. My "new_submission" Notification email has one template in app/views/notifications/new_submission.merb. Then in app/mailers/notifications.rb, all you need to do is
mail(:to => Person.editor.email) do |format|
format.text
format.html
end
And the single .merb template gets compiled into both the text and html part of a multipart email. Woohoo! You can read more about this in an excerpt from Crafting Rails, and you can browse around my specific implementation of it.
Somewhere, somehow, something went wrong
I updated my Gemfile about a week ago, and thought I got everything working because my pages were loading and Compass and Sass were no longer grumbling at me. For some horrible reason I didn't run any of my tests. But it turns out I've been getting this error since then whenever I call an action (such as "packlet.destroy") that tries to send this new_submission email:
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'
Line 26 of app/mailers/notifications is the "format.html" line, shown above.
I have narrowed this down to a problem with haml/sass 3.1 by doing this bundle update more granularly. I updated Rails, ran my tests, no problems. I updated haml, ran my tests, and this pops out in four places.
Any guidance would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Haml 3.1 中的一个已知问题,由注释中嵌套内容引起。 (这是我从 haml 的创建者本人那里学到的。)
This is a known issue in Haml 3.1, caused by nesting content within comments. (I learned this from haml's creator himself.)