Jun 12, 2025
/
Speaking
The Best Way to Structure AI in Rails: MVC with Agents, Prompts, and Views (From SF Ruby)
By Rhiannon Payne
What does AI development in Rails look like when you treat Agents like Controllers and Prompts like Views?
At SF Ruby on June 4th (hosted by Irina Nazarova and Evil Martians at Chime), Justin Bowen posed this exact question and demonstrated how Active Agent brings AI into your Rails apps in a truly Rails-native way, using familiar MVC patterns.
Watch here and go to 1:54:00 for Justin's talk:
Why Agent-Oriented Programming?
Instead of relying on brittle chains of API calls, Active Agent is a free open source framework that uses an Agent-Oriented Programming (AOP) approach to build AI features in Rails, turning AI logic into classes with intent and actions, not just data and methods.
Originally coined over 30 years ago, AOP flips the script on traditional OOP. Think of Agents as intelligent objects with a “persona." They can make decisions, call tools, and take actions. It’s a natural fit for AI development.

Extending AbstractControllers
This diagram, based on the Rails Guides (with the Active Agent logo slapped on and a few things moved around 😅), reframes how Agents fit into the Rails mental model:

Agents = Controllers: Your AI logic lives in Agent classes, where each public method becomes an “action.”
Prompts = Views: Like ERB templates, prompts can be rendered dynamically and reused across different contexts.
Prompt Content = Model/Data: The raw data that gets processed, embedded, or transformed by the agent’s logic.
By extending AbstractController, Active Agent gives your AI components lifecycle hooks, parameter handling, and familiar Rails patterns, so building AI apps actually feels like building with Rails.
Under the Hood: Familiar Rails Patterns
In his talk, Justin showed us some of the ways that Active Agent leverages Rails patterns under the hood:
Agents use lifecycle hooks like before_generation and after_generation, similar to Controller callbacks.
Responses can stream in chunks, supporting interactive UI updates.
Actions can trigger background jobs using generate_later, just like deliver_later in ActionMailer.
New Docs Coming Soon
We've heard your feedback, and better docs (with examples) are on the way! Justin previewed the new documentation at SF Ruby, including hands-on examples for:
Defining Agents and Prompts
Setting up message flows
Using prompt templates as dynamic views
Expect that to go live along with a big release VERY soon. We'll share on social and in our Discord channel when it happens!
Get Involved
If you’re ready to bring AI into your Rails app the right way, Active Agent is the framework for you!
Here’s how you can connect with Justin or get involved with Active Agent…
🛠️ Try it out (and open issues or submit a PR!)
💬 Join the Active Agent Discord
✨ Hire Justin to work on your AI project
📩 Email Justin at justin@activeagents.ai or schedule a call just to chat