Skip to content

Getting Started with Rails 7 Episode 4: Model CRUD in the Rails Console and Listing Articles

This is the 4th video in the Getting Started with Rails 7 series. In this video Mike explores the Rails console with the Article model and the ability to Create, Read, Update, and Destroy (CRUD) Article records in the console. After that he takes a quick look at the Rails database console, customizes some Rails fixtures, updates the controller test, and adds in the changes to the ArticlesController and index template to display a list of articles.

This video covers:

  • 00:00:10 Introduction
  • 00:01:17 Launch the Rails Console and explain the IRB REPL environment
  • 00:02:43 Initialize and save an article
  • 00:05:17 Update the article and save again
  • 00:07:03 Add a second article using the Article.create method and change to length of Article.all
  • 00:07:57 Assign an article to a variable with Article.find
  • 00:09:25 Destroy an article that you don’t want
  • 00:11:24 Quick exploration of the Rails DB console (using SQLite3 in this case)
  • 00:12:24 Modify the ArticlesController index action to query all articles and assign to an instance variable
  • 00:14:12 Change the controller test to account for the upcoming changes in the index view
  • 00:15:50 Make the fixtures less boring and validate in the Rails console for the test environment after fumbling around a bit
  • 00:19:12 Modify the index.html.erb to make the tests pass and explain the template code
  • 00:23:04 Talk through the ArticlesController index request-response cycle
  • 00:24:08 Review, commit, and push code changes

The code for this series is open source and available on GitHub. View the commit for this video here.

Leave a Reply