O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2Building Models with Active Model

  • Active Model and its modules

  • How to make an object comply with the Active Model API required by Rails

  • Rails’s validators and Ruby-constant lookup

In the previous chapter, we talked briefly about Abstract Controller and how it reduced code duplication in the Rails source code since it’s decoupled from both Action Mailer and Action Controller. Now let’s look at Active Model, which is similar.

Active Model was originally created to hold the behavior shared between Active Record and Active Resource.[15] As with Abstract Controller, the desired functionalities can be cherry-picked by including only the modules you need. Active Model is also responsible for defining the application programming interface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required