Rails Decouples Trix From Action Text Into action_text-trix gem

Action Text is a power-packed tool designed to build WYSIWYG editors for our Rails applications easily. Action Text brings rich text content and editing to Rails.

Trix

Trix is developed by Basecamp.

According to its official website:

Trix is an editor for writing messages, comments, articles, and lists—the simple documents most web apps are made of. It features a sophisticated document model, support for embedded attachments, and outputs terse and consistent HTML.

We can read more about Trix, all the features it offers, and what are its advantages over most other WYSIWYG editors over here.

Before

Historically, Trix was bundled directly with Action Text in Rails, meaning that updating Trix often depended on a new Rails release.

This tight coupling could slow down the adoption of new Trix features or, more critically, security fixes.

Another common approach involved using the Trix npm package. If we used bin/importmap pin to manage Trix in our Rails application, the npm package would be downloaded and vendored into our vendor folder. While this offered some flexibility, it introduced its own set of issues like CSS management and false vulnerability reports.

After

Recognizing these challenges, Rails extracted Trix into a separate gem called action_text-trix. This gem lives inside the Trix repository itself.

The primary benefit of this new gem is that it allows Action Text and Trix to be upgraded independently. This is especially crucial for security updates, as the action_text-trix gem can now be released right alongside the Node module, providing much faster access to critical fixes.

For New Rails Apps

Installing Action Text automatically adds the gem:

bin/rails action_text:install

All JS and CSS dependencies are managed for us — no manual setup needed if using Importmap or ESBuild.

Enables Trix-powered rich text editing out of the box.

For Existing Rails Apps

  1. Add the gem

    Add the action_text-trix gem to Gemfile:

     gem "action_text-trix"
    

    Then run:

     bundle install
    
  2. Delete vendored Trix files (if any)

    If we previously copied trix.js and trix.css into vendor/ or imported Trix via npm/yarn, remove those files. This ensures our app uses the version provided by the gem.

  3. Unpin or update Trix in config/importmap.rb

    If we previously ran:

     bin/importmap pin trix
    

    …and have this line in config/importmap.rb:

     pin "trix", to: "trix.js"
    

    Remove it, or update it to avoid conflicts:

     # Comment this out if using the gem-provided version
     # pin "trix", to: "trix.js"
    

This ensures Importmap loads the correct Trix version from the gem, not an outdated or conflicting one.

Compatibility:

The action_text-trix gem’s specification does not specify any dependencies on Rails versions, meaning we can use it with any version of Rails as long as we have Railties.

This move streamlines Trix integration, simplifying asset management, and making upgrades far less painful and also easier to replace Trix with other editors like TipTap or Quill if needed.

Key Takeaways

  • Problem: Trix was tightly coupled with Action Text in Rails, making updates and security fixes slow and dependent on Rails releases.
  • Solution: Trix is now decoupled into the action_text-trix gem, allowing independent and faster updates.
  • Installing Action Text in new Rails apps automatically adds and configures the action_text-trix gem.
  • Existing apps should remove any manually managed or vendored Trix files and update their Importmap configuration to avoid conflicts.
  • Asset management is now streamlined—no need to manually handle Trix JS/CSS files or npm packages.
  • Upgrading Trix or swapping to another editor (like TipTap or Quill) is now much easier.

Quick references

Need help on your Ruby on Rails or React project?

Join Our Newsletter