© Greg Donald 2024
G. DonaldHands-on Test-Driven Developmenthttps://doi.org/10.1007/978-1-4842-9748-3_6

6. Adding Initial Models

Greg Donald1  
(1)
Clarksville, TN, USA
 

In this chapter, we will add our first two Rails ActiveRecord models into our blog application. We will start with simple User and Page models and proceed to grow them, adding more functionality as we go along.

Ruby on Rails is overflowing with code generators. Rails code generators create lots of code for us when we run them. We can use the rails generate command, for example, to quickly generate a fully namespaced model or a controller with actions and views stubbed and ready for additional development. And since we already have RSpec and FactoryBot installed, we will get appropriately ...

Get Hands-on Test-Driven Development: Using Ruby, Ruby on Rails, and RSpec 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.