# 486: ActiveModel Everywhere Page: https://stenobird.com/podcast/the-bike-shed/486-activemodel-everywhere Text version: https://stenobird.com/podcast/the-bike-shed/486-activemodel-everywhere.md Podcast: [The Bike Shed](https://stenobird.com/podcast/the-bike-shed) Published: 2025-12-23T08:00:00+00:00 Episode link: https://bikeshed.thoughtbot.com/486 Audio file: https://aphid.fireside.fm/d/1437767933/167c01a1-0eb9-4640-b488-c2f6d6866650/67250911-85b0-4967-ab56-cee3c482a368.mp3 Processing state: processed JSON: https://stenobird.com/v1/public/podcasts/the-bike-shed/episodes/486-activemodel-everywhere Duration seconds: 1631 ## Resource Stop reinventing the wheel with plain old Ruby objects and start leveraging ActiveModel for non-database logic. Learn how to bring Rails-style validations, attributes, and consistency to any part of your application. ## Highlights - Main idea: Use ActiveModel to provide a consistent, familiar interface for objects that don't require a database - Practical takeaway: Implement ActiveModel::Attributes and ActiveModel::Validations to gain robust, well-tested logic for free - Failure mode: Avoid building custom helper methods and manual validation logic in POROs, which increases testing complexity - Practical takeaway: Treat your application resources as domain objects that can utilize Rails' powerful toolset regardless of persistence - Main idea: Leveraging ActiveModel makes objects compatible with existing Rails ecosystem tools like FactoryBot and view helpers ## Topics Ruby on Rails, ActiveModel, ActiveRecord, Software Architecture, Data Validation, Object-Oriented Programming, Testing Patterns, Domain Driven Design ## Chapters - 7:00 — The Power of Consistency: Discussing the benefits of using ActiveModel to provide consistent thought and robust, pre-tested validators across different application paths. - 9:00 — Everything is a Resource: Exploring the concept of treating all application behaviors as resources and applying Rails tools to cross-cutting concerns. - 11:05 — Mimicking Rails Controllers: How to structure non-database models so they look and feel like standard Rails controllers to maintain developer familiarity. - 13:10 — Attributes and Validations: A deep dive into using ActiveModel to handle attribute instantiation and standard Rails-style validations without ActiveRecord. - 15:05 — The Cost of Manual Implementation: Reflecting on the difficulty of recreating the Rails magic—like testing with FactoryBot—when using plain Ruby objects. - 17:00 — Understanding the Rails Ecosystem: Distinguishing between 'Active' and 'Action' components and how small, interconnected units form the Rails framework. - 21:00 — Integrating with Views: Using ActiveModel to create objects that work seamlessly with Rails views, partials, and existing helper methods. ## Actions - request_transcript: `POST https://stenobird.com/v1/public/podcasts/the-bike-shed/episodes/486-activemodel-everywhere/transcription-requests` — Idempotently request low-priority transcript generation for this episode. - read_markdown: `GET https://stenobird.com/podcast/the-bike-shed/486-activemodel-everywhere.md` — Read the agent-friendly Markdown representation of this episode resource. A page view does not enqueue transcription. Agents should invoke `request_transcript` explicitly when they need this episode processed. ## Transcript Full transcripts are not published on public pages unless there is a clear rights basis.