简体   繁体   中英

accessing helpers in ApplicationController.render in Rails 6

I'm using a Sprockets pre-processor to generate static HTML error pages for my app with this:

ApplicationController.renderer
  .new({
    http_host: 'myhost',
    https: Rails.env != 'development'
  })
    .render({
      inline: asset[:data],
      layout: 'layouts/error_page'
    })

The HTML comes in via asset[:data] , and a I render that with the error_page layout. This worked without issue in Rails 5, but since upgrading to 6 none of my custom helper methods are accessible if they're in the inline part of the render:

NameError: undefined local variable or method `my_custom_helper' for #<#<Class:0x00000000061b2758>:0x00007fe24c03bc28>

They do work if they're in the layout though, any idea what I'm missing?

内联文件是.html.erb ,将它们重命名为.html足以让它与 Rails 6 一起工作。 NameError 在预处理器被调用之前就发生了,我猜链轮正在尝试解析 ERB在它之前。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM