April 9, 2025

I recently added a Rails Generator to the trix-genius gem — a small improvement that aims to make integration smoother and faster for developers using Trix with Rails and Stimulus.

👉 TL;DR: rails generate trix_genius:install now does the setup for you.


💬 Need a Custom Ruby Gem for Your App?


If you're looking for a custom-built gem to streamline your application, optimize your workflow, or integrate with third-party tools — I’d be happy to help.


🚀 Let's Build Something Together


✨ What It Does

Running the new generator:

bin/rails generate trix_genius:install

…will now:

✅ Create an initializer at config/initializers/trix_genius.rb

✅ Inject the required imports into your app/javascript/application.js

✅ Register the Stimulus controller in app/javascript/controllers/application.js

✅ Generate a basic Stimulus controller at app/javascript/controllers/trix_genius_controller.js

This helps eliminate manual steps and reduces the chances of integration issues. The goal is to plug in the gem and get going with minimal setup friction.


🧪 Specs and Confidence

To keep things solid, I added generator specs using generator_spec. They simulate the structure of a real Rails app and confirm that all files and updates happen as expected.

it "updates application.js with import line" do
  run_generator
  assert_file "app/javascript/application.js" do |content|
    expect(content).to include('import "trix"')
  end
end

🔍 Check It Out

🔗 Code: github.com/ggerman/trix_genius/tree/feature/add-generators-and-spec

📦 Gem: rubygems.org/gems/trix-genius

Install it in your project:

gem 'trix-genius', '~> 0.0.13'

This is part of my ongoing effort to make small tools that simplify Rails dev life. Hope it helps! If you try it or have suggestions, feel free to drop a comment or open an issue.

Happy coding! 🚀


✅ Wrapping Up

This new generator is a small but meaningful step toward improving the developer experience with trix-genius. By automating repetitive setup tasks and offering a plug-and-play install process, it helps developers focus more on building features and less on wiring things up.

Whether you’re spinning up a new project or integrating Trix into an existing one, this should help streamline the process and keep your app structure clean and consistent.

I’m always open to feedback, improvements, or ideas — feel free to reach out or contribute!

Thanks for reading 🙌 Let’s keep making Rails even more joyful to work with. ❤ 💎

Article content