How to reference ActionText::RichText from outside Rails app?

For testing the integration of the Mobility translation library with ActionText rich text, there would need to be a way to load the ActionText::RichText class even if not in the context of a Rails app. However simply referencing the class yields the error uninitialized constant ActionText. Maybe it’s because of some missing autoloading mechanism? Is there any way to require the class (tried adding require "action_text/rich_text" to no avail)?

There’s no autoloading in Rails gems.

In order to use a Rails component, you need to load its main file first:

require "action_text"
require "action_text/..."

lib/action_text.rb is responsible for the definition of the ActionText module (source code).

Thank you Xavier. I remember having tried that but getting issues. In the end I created a new gem with a Rails app to run the tests:

1 Like