DEV Community

Germán Alberto Gimenez Silva
Germán Alberto Gimenez Silva

Posted on • Originally published at rubystacknews.com on

🚀 Introducing TrixGenius Alpha 0.1.4 – Now with AI-Powered Math Evaluation!

TrixGenius Alpha 0.1.4
TrixGenius Alpha 0.1.4

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.

Article content


✨ 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.

đź§  Under the hood:

  • 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.

🎥 Here’s what it looks like:

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"
Enter fullscreen mode Exit fullscreen mode

It’s all scaffolded into your app with a single command:

bin/rails g trix_genius:install
Enter fullscreen mode Exit fullscreen mode

🧪 Still in Alpha — But Growing Fast

Article content

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'
Enter fullscreen mode Exit fullscreen mode

Then run the install generator:

bundle install
bin/rails g trix_genius:install
Enter fullscreen mode Exit fullscreen mode

Demo it with Action Text + a simple scaffold:

bin/rails g scaffold Post title:string content:rich_text
Enter fullscreen mode Exit fullscreen mode

Article content
Calculate Expression

Article content
Trix Genius


🙌 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! 🔧 💡

RubyOnRails #Hotwire #TrixEditor #StimulusJS #AI #OpenSource #DevTools #RubyGems

Article content

Top comments (0)