问题描述
我正在使用 ActionText 来编辑一个段落,它在本地工作得很好,但是当我将它部署到 Heroku 时,即使我遵循了 rails 指南,但当我将它部署到具有 Rich_text_area 表单的页面时,它仍会抛出一个错误,指出未定义的方法 rich_text_area_tag.我以为我需要在生产环境中配置 Active Storage,但事实并非如此.
I am using ActionText to edit a paragraph and it works perfectly locally but when I deploy it to Heroku the page which has the form with rich_text_area it throws an error saying undefined method rich_text_area_tag even though I followed the rails guide. I thought I needed to configure Active Storage on production but that's not the case.
这是我在 Heroku 的日志中得到的信息:ActionView::Template::Error(未定义方法 'rich_text_area_tag' for #<#<Class> 你的意思是?rich_text_area)
Here is what I am getting in Heroku's logs:ActionView::Template::Error (undefined method 'rich_text_area_tag' for #<#<Class> Did you mean? rich_text_area)
<%= f.label :something, class:'label' %>
<%= f.rich_text_area :something %>
推荐答案
我在网上找到了这个,对我很有帮助:
I found this online, and it was helpful for me:
https://github.com/JoeWoodward/spree_helper_issue
我不确定这是否是正确的方法,但这是一种临时解决方法.
I am not sure if this is the correct way to do it, but it's a temporary workaround.
解决方案:
在 application_controller.rb
中输入以下内容:
In application_controller.rb
enter the following:
require 'action_text'
class ApplicationController < ActionController::Base
helper ActionText::Engine.helpers
...
end
helper
文档:https://apidock.com/rails/AbstractController/Helpers/ClassMethods/helper
这篇关于Rails 6 ActionText 不适用于 Heroku(未定义方法“rich_text_area_tag")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!