Learn to Make an API-Backed Model with
summary
Shows how a Rails model can be backed by an external API rather than a database, using ActiveModel::Attributes (Rails 5.2) for typed coercion, the square_connect Ruby SDK to call Square’s Customers API, and standard Rails bits like Pagy for pagination. One include (ActiveModel::Model) brings in five convenience modules; adding ActiveModel::Dirty requires just two method hooks to get change tracking. A Customer model plus controllers and views are implemented and demoed performing fetch, create, update, delete and pagination successfully.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:40Active Model
- 2:40Attributes API
- 3:44Square Customer API
- 5:42Square Model Callbacks
- 7:29ActiveModelDirty
- 9:21ActiveModelDirty Demo
- 11:11ActiveModelSerializers
- 12:00ActiveModelValidations
- 13:09Naming and Translation
- 14:08Lint Test
- 15:09Pretty Print Inspect
- 19:39Inspect Object ID
- 21:02Inspect Class
- 21:38Demo
- 27:30Questions
related talks
22mBryan's ActieModel Extravaganza
24mBuild The API First
31mActiveSupport and ActiveModel
46mRails as a piece of birthday cake
27mRediscovering ActiveRecord
38mDesigning a Great Ruby API - How We're Simplifying Rails 5
42mPowerful Rails Features You Might Not Know
40mWriting APIs the Easy Way with Rails API and AMS
