ruby-on-rails - Rails 6 ActionController::Base.new.render_to_string
问题描述
将我的 Rails 应用程序从 5.2 更新到 6 后,render_to_string 停止工作。
代码
ActionController::Base.new.render_to_string(file: Rails.root.join('test.html.erb'), locals: { foo: 'bar' })
test.html.erb
<%= foo %>
预期的
bar
当前的
<%= foo %>
它以前工作过,在更新到 Rails 6 之后,它只是输出文件内容而不对其进行评估。
PS.:我也尝试使用 ApplicationController API (ApplicationController.render),同样的行为。
我错过了什么吗?
解决方案
推荐阅读
- linux - Linux - sed - 从配置文件编辑 java opts
- android - 在 android studio 包名称中更改域扩展
- php - 如何在 PHP 中用逗号分割字符串
- python - 从另一个有条件的张量创建一个张量
- c# - 第二种形式在调试模式下加载,但在从 Executable 运行时不加载
- html - 如何使用css在标签上突出显示div中的元素
- json - 如何强制 Azure 策略中主机名的名称模式?
- python - 如何正确处理“despine”功能以避免错误消息
- ios - iOS - 在 WKWebView 中使用 cookie
- selenium - 如何在 RIDE 中单击单击事件上具有 javascript 的行