首页 > 解决方案 > Rails 6 ActionText 不适用于 Heroku(未定义的方法 'rich_text_area_tag')

问题描述

我正在使用 ActionText 来编辑一个段落,它在本地工作得很好,但是当我将它部署到 Heroku 时,即使我遵循了 rails 指南,它也会抛出一个错误,说 undefined method rich_text_area_tag 。我以为我需要在生产环境中配置 Active Storage,但事实并非如此。

这是我在 Heroku 的日志中得到的信息: 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 %>

标签: ruby-on-railsherokuruby-on-rails-6actiontext

解决方案


我在网上找到了这个,它对我很有帮助:

https://github.com/JoeWoodward/spree_helper_issue

我不确定这是否是正确的方法,但这是一种临时解决方法。

解决方案:

application_controller.rb输入以下内容:

require 'action_text'

class ApplicationController < ActionController::Base
  helper ActionText::Engine.helpers

  ...
end

文档helperhttps ://apidock.com/rails/AbstractController/Helpers/ClassMethods/helper


推荐阅读