April 15, 2025
I just released a new version of my Rails engine and gem: TrixGenius! This gem extends the beloved Trix Editor with some fresh, AI-powered superpowers — all using Hotwire (Turbo + Stimulus).
Whether you’re building internal tools, CMS interfaces, or AI-enhanced content platforms, TrixGenius gives your rich text editor a serious productivity boost.
What’s New in Alpha 0.1.2?
This update introduces a brand-new feature that I’m super excited about:
Calculate Math Expressions with a Single Click!
Users can now type math expressions inside the Trix editor (like (5 + 3 * 2)), hit the new “Calculate” button, and automatically get the result injected back into the content.
- Detects top-level math expressions in parentheses.
- Uses a secure Ruby evaluator to compute results (e.g., (3+4*2) becomes 3+4*2=11).
- Optionally calls an AI (e.g., DeepSeek) to reformat the text while preserving the original context.
Input: Let’s compute (8/2+3*2).
Result after clicking “Calculate”: Let’s compute 8/2+3*2=10.
Need Help Building AI-Powered Tools in Rails?
If you’re looking to enhance your Rails app with AI , improve your editor experience, or just want someone to help you ship smarter features faster — I’d love to chat.
I specialize in:
-
Ruby on Rails development
-
AI integrations (OpenAI, DeepSeek, custom APIs)
-
Hotwire (Turbo + Stimulus)
-
Building and maintaining custom gems and engines
Let’s connect: rubystacknews.com/get-in-touch
Happy to explore how we can build something great together.
How it Works – Under the Hood
The magic happens through:
A Stimulus Controller
- Adds a “Calculate” button to the Trix toolbar.
- Collects the editor content.
- Sends it via AJAX to your Rails backend for evaluation.
A Rails Endpoint (/trix_genius/calculate_expression)
- Securely parses and evaluates expressions.
- Integrates optional AI enhancement.
- Returns transformed HTML content.
Generator Updates
The gem now automatically injects this route:
# TrixGenius: Auto-added route
post "/trix_genius/correct_spelling", to: "trix_genius#correct_spelling"
It’s all scaffolded into your app with a single command:
bin/rails g trix_genius:install
Still in Alpha — But Growing Fast
This gem started with a simple idea: make Trix smarter. The first feature was a “Correct Spelling” button. Now, we’ve added math evaluation , and we’re already working on:
- Integrating ChatGPT & Qwen.ai
- Feature toggles (enable/disable toolbar buttons)
- Specs for all features
Try It Out
You can install the gem from RubyGems:
gem 'trix-genius', '~> 0.1.4'
Then run the install generator:
bundle install
bin/rails g trix_genius:install
Demo it with Action Text + a simple scaffold:
bin/rails g scaffold Post title:string content:rich_text
Feedback Welcome
This is an early release, and I’d love to hear what you think — feature requests, issues, and ideas are more than welcome.
Feel free to reach out or follow the repo to stay updated: https://github.com/ggerman/trix_genius
Let’s build smarter content tools for Rails devs!
Top comments (0)