Rails 6 ActionText isn't working on Heroku (undefined method 'rich_text_area_tag') Rails 6 ActionText isn't working on Heroku (undefined method 'rich_text_area_tag') heroku heroku

Rails 6 ActionText isn't working on Heroku (undefined method 'rich_text_area_tag')


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

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


First of all make sure that you have this line in config/application.rb:

require 'rails/all'

If it's a rails 6 app action_text/engine should be loaded.

If it doesn't it's possible taht zeitwerk is not loaded. This happens when you have a rails 5.2 app that was updated to rails 6.

In the same file (config/application.rb) you have to change config.load_defaults to 6.0:

config.load_defaults 6.0

If you want to know what happens in the background take a look at this link on line 125.


To avoid cluttering the ApplicationController code, you can use an initializer:

i.e. add a new file config/initializers/action_text.rb:

ActiveSupport.on_load(:action_view) do  include ActionText::ContentHelper  include ActionText::TagHelperend

Inspired by p8's comment in a closed Rails issue.