Rails Concepts
In Chapter 3, The Architecture of Rails Applications we introduced models, views, and controllers. Now let’s see how we applied each of these concepts in the Depot application. Then let’s explore how we used configuration, testing, and deployment.
Model
Models are where all of the persistent data retained by your application is managed. In developing the Depot application, we created five models: Cart, LineItem, Order, Product, and User.
By default, all models have id, created_at, and updated_at attributes. To our models, we added attributes of type string (examples: title, name), integer (quantity), text (description, address), and decimal (price), as well as foreign keys (product_id, cart_id). We even created a virtual attribute ...
Get Agile Web Development with Rails 5.1 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.