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

🐙 Find Justin on Bluesky, X, LinkedIn, Github

Read More

Check out more content about new releases and AI concepts, written by Active Agent creator Justin Bowen.

Check out more content about new releases and AI concepts, written by Active Agent creator Justin Bowen.

Jun 12, 2025

What does AI development in Rails look like when you treat Agents like Controllers and Prompts like Views? Justin Bowen, creator of Active Agent, explores this question at SF Ruby.

Jun 12, 2025

What does AI development in Rails look like when you treat Agents like Controllers and Prompts like Views? Justin Bowen, creator of Active Agent, explores this question at SF Ruby.

Jun 12, 2025

What does AI development in Rails look like when you treat Agents like Controllers and Prompts like Views? Justin Bowen, creator of Active Agent, explores this question at SF Ruby.

Jun 12, 2025

What does AI development in Rails look like when you treat Agents like Controllers and Prompts like Views? Justin Bowen, creator of Active Agent, explores this question at SF Ruby.

Mar 15, 2025

More than an AI gem, Active Agent brings AI development in line with MVC conventions with AI agents as controllers.

Mar 15, 2025

More than an AI gem, Active Agent brings AI development in line with MVC conventions with AI agents as controllers.

Mar 15, 2025

More than an AI gem, Active Agent brings AI development in line with MVC conventions with AI agents as controllers.

Mar 15, 2025

More than an AI gem, Active Agent brings AI development in line with MVC conventions with AI agents as controllers.

Mar 12, 2025

Build AI agent apps in Rails with Active Agent. New release includes improvements to streaming, less config, and bug fixes.

Mar 12, 2025

Build AI agent apps in Rails with Active Agent. New release includes improvements to streaming, less config, and bug fixes.

Mar 12, 2025

Build AI agent apps in Rails with Active Agent. New release includes improvements to streaming, less config, and bug fixes.

Mar 12, 2025

Build AI agent apps in Rails with Active Agent. New release includes improvements to streaming, less config, and bug fixes.

Mar 7, 2025

Watch as we refactor a Rails RAG system on thoughtbot’s livestream, replacing custom AI logic with Active Agent for a cleaner, Rails-native approach.

Mar 7, 2025

Watch as we refactor a Rails RAG system on thoughtbot’s livestream, replacing custom AI logic with Active Agent for a cleaner, Rails-native approach.

Mar 7, 2025

Watch as we refactor a Rails RAG system on thoughtbot’s livestream, replacing custom AI logic with Active Agent for a cleaner, Rails-native approach.

Mar 7, 2025

Watch as we refactor a Rails RAG system on thoughtbot’s livestream, replacing custom AI logic with Active Agent for a cleaner, Rails-native approach.

Feb 20, 2025

NEW: Active Agent 0.2, a production-ready release candidate so you can start building AI features or refactoring your Rails apps today.

Feb 20, 2025

NEW: Active Agent 0.2, a production-ready release candidate so you can start building AI features or refactoring your Rails apps today.

Feb 20, 2025

NEW: Active Agent 0.2, a production-ready release candidate so you can start building AI features or refactoring your Rails apps today.

Feb 20, 2025

NEW: Active Agent 0.2, a production-ready release candidate so you can start building AI features or refactoring your Rails apps today.

Sep 10, 2024

In most cases, integrating AI isn’t as simple as just plugging in ChatGPT’s API—and without proper implementation, it can lead to critical business mistakes.

Sep 10, 2024

In most cases, integrating AI isn’t as simple as just plugging in ChatGPT’s API—and without proper implementation, it can lead to critical business mistakes.

Sep 10, 2024

In most cases, integrating AI isn’t as simple as just plugging in ChatGPT’s API—and without proper implementation, it can lead to critical business mistakes.

Sep 10, 2024

In most cases, integrating AI isn’t as simple as just plugging in ChatGPT’s API—and without proper implementation, it can lead to critical business mistakes.

Ready to build AI products with Rails?

Copyright © 2025 Active Agent / Justin Bowen

Website & marketing by Sea Foam Media, the premiere agency for AI products & dev tools.

Active Agents Newsletter

Subscribe to receive occasional updates, news, and content from Active Agents.

Ready to build AI products with Rails?

Copyright © 2025 Active Agent / Justin Bowen

Website & marketing by Sea Foam Media, the premiere agency for AI products & dev tools.

Active Agents Newsletter

Subscribe to receive occasional updates, news, and content from Active Agents.

Ready to build AI products with Rails?

Copyright © 2025 Active Agent / Justin Bowen

Website & marketing by Sea Foam Media, the premiere agency for AI products & dev tools.

Active Agents Newsletter

Subscribe to receive occasional updates, news, and content from Active Agents.