@StatelessCode
  @StatelessCode
Stateless Code | Codecast: Getting Started with Rails 7 08: Model Validations and Form Error Messages @StatelessCode | Uploaded December 2021 | Updated October 2024, 4 hours ago.
This is the 8th video in the Getting Started with Rails 7 series. In this video Mike demonstrates that you can currently create an Article record with an empty title and body. In order to solve the problem, he uses Rails model validations to ensure the data for the Article record is in good order before trying to save to the database. He first creates failing tests in the ArticleTest model test class and then adds in the validations to make them pass. After that, he adds embedded Ruby to the new view template to display the error messages in the view if any exist.

This video covers:
00:00:10 Introduction and demonstrate lack of validations
00:02:55 Write failing model tests in ArticleTest class, both happy and unhappy paths
00:09:13 Add validations to the article model incrementally to make tests pass
00:11:27 Review the validation error message view code in the guide
00:17:30 Add test for bad parameters to ArticlesControllerTest and troubleshoot assert_select unexpected behavior. Solve by adding classes to the error message divs.
00:24:10 Add back in the error messages to the view to make the tests pass and explore in the application UI
00:25:05 Review the rest of this section of the guide. Demonstrate preservation of bad form input data if invalid
00:25:50 Add link_to helper in articles index view to new article form
00:29:11 Review, commit, and push the code

This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.
Codecast: Getting Started with Rails 7 08: Model Validations and Form Error MessagesWhy Test Driven Development?Remix One of Your Existing Videos into a YouTube ShortCodecast: statelesscode.com WordPress 24: Style the Comment FormCodecast: statelesscode.com WordPress 09: Use Flexbox to Position Sidebar and Add StylingCodecast: Getting Started with Rails 7 09: Update an Article and Use Form PartialsAdd a CONTRIBUTING.md File to the Project to Help with CollaborationCreate a RubyGem 91: Add a Security Policy to the GemCodecast: Getting Started with Rails 7 01: Install, Create Project, and Start ServerCodecast: Create a RubyGem 77: Add Default Behavior for Advantage if Number to Keep not SpecifiedInkscape 05: Create Stateless Code Inkscape LogoUpdate a Rails 7 Application to use Ruby 3.2

Codecast: Getting Started with Rails 7 08: Model Validations and Form Error Messages @StatelessCode

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER