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

Wrapping Up

In this chapter, we covered how to use Active Model to quickly create our own models that play seamlessly with Rails controllers and views. We talked about ActiveModel::AttributeMethods, ActiveModel::Conversion, ActiveModel::Naming, ActiveModel::Translation, ActiveModel::Validations, and finally ActiveModel::Callbacks. We also dove into Rails validators and how we can easily extend the validates method behavior.

Even after all that, Active Model has a couple other modules to explore, like ActiveModel::Dirty and ActiveModel::Serialization. They let us bring dirty attributes and serializers such as to_xml and to_json right into our models, just like Active Record models.

Finally, if you enjoyed Mail Form here, check out the Mail ...

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