Rails 6 ActionText在Heroku上不起作用(未定义的方法'rich_text_area_tag')

Gro*_*fen 8 ruby-on-rails heroku ruby-on-rails-6 actiontext

我正在使用ActionText编辑一个段落,并且该段落在本地完美运行,但是当我将其部署到Heroku时,页面的格式为rich_text_area,即使我遵循了rails指南,也会抛出一个错误,提示未定义的方法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 %>
Run Code Online (Sandbox Code Playgroud)

Vio*_*eta 7

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.

SOLUTION:

In application_controller.rb enter the following:

require 'action_text'

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

  ...
end
Run Code Online (Sandbox Code Playgroud)

Docs for helper: https://apidock.com/rails/AbstractController/Helpers/ClassMethods/helper

  • 就像一个魅力一样,做一点改动:```helper ActionText :: Engine.helpers```(否“ s”)我相信这是一个错字:) (3认同)