April 10, 2025
After many late-night commits, experiments, and way too much mate — I’m incredibly excited to introduce the alpha release of a gem I’ve been crafting with love:
TrixGenius — A smart extension for Trix + ActionText + Hotwire.
Want to Add AI to Your Ruby on Rails App?
If you’re looking to bring AI features like spelling correction, natural language processing, or smart assistants into your Rails application, I’d love to help!
What is TrixGenius?
TrixGenius is a Rails engine and generator that adds AI-powered buttons to your Trix Editor using Stimulus and Turbo.
In this alpha version, I’m proud to ship a working button that uses AI (DeepSeek or your favorite API) to automatically correct spelling in Trix inputs — all with a single click.
This is just the beginning. The idea is to enhance the Trix experience with intelligent, modular enhancements that plug into your Rails app easily.
What’s Included in the Alpha?
AI button: “Correct Spelling” via API
rails g trix_genius:install generator
Fully Stimulus-powered Trix extension
Ready-to-hack Stimulus controller for more IA buttons
Get trix-genius
The first alpha release</strong of trix-genius
is now available! Enhance your Trix editor with AI-powered features today.
Gem name:
trix-genius
Version:
0.1.0
# Gemfile
gem "trix-genius", "~> 0.1.0"
Installation (Rails 7 / JS Bundler or Importmap)
Add to your Gemfile:
gem "trix_genius"
Then install ActionText if you haven’t yet:
bin/rails action_text:install
Create a scaffold (optional):
bin/rails g scaffold Post title body:rich_text bin/rails db:migrate
Then run the gem’s generator:
bin/rails g trix_genius:install
This will:
- Create the initializer
- Inject needed imports in application.js and controllers/application.js
- Add the controller (trix_genius_controller.rb)
- Add JS controller (trix_genius_controller.js)
- Inject the route:
post "/trix_genius/correct_spelling", to: "trix_genius#correct_spelling"
Generator Spec Coverage
Yes, this gem ships with RSpec tests for the generator! Here’s an example:
it "adds AI route to correct spelling" do
run_generator
assert_file "config/routes.rb" do |content|
expect(content).to include('post "/trix_genius/correct_spelling"')
end
end
You’ll find specs covering:
- Route injection
- Stimulus controller creation
- application.js updates
- Fallback warnings when files don’t exist
Extensible by Design
Want to add more buttons like:
- Summarize Text
- Translate Paragraph
- Rephrase for Tone
Just extend the controller or hook into the route and Stimulus actions — it’s designed to be hackable.
Developer Experience Matters
We believe in:
- Zero config
- Instant feedback
- Helpful messaging
- Undo safety
That’s why our generator not only creates files but gives fallback messages with example content, like this:
def javascript_application_msg
<<~MSG
 You should create the file manually:
 app/javascript/application.js
 With the following content:
...
MSG
end
Why I Built This
I wanted a way to make rich text editing smarter and more helpful, especially for apps where users are writing a lot. Whether it’s blog platforms, admin panels, or messaging systems — helping users write better and faster just made sense.
And of course… I wanted a smooth install. I hate wiring things up manually. This gem does the setup for you.
Try It Out or Collaborate!
Check out the code, give it a spin, and feel free to open issues or ideas:
GitHub – TrixGenius
gem ‘trix_genius’
Big shoutout to the amazing OSS ecosystem around Rails, Hotwire, and Stimulus that makes building stuff like this so fun.
If you’re building AI features into Rails apps or love messing with rich-text UX — let’s connect and share ideas!
Top comments (0)