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 ...

Get Crafting Rails 4 Applications, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.