@StatelessCode
  @StatelessCode
Stateless Code | Codecast: Getting Started with Rails 7 16: Refactor Repeated Code Using Concerns @StatelessCode | Uploaded January 2022 | Updated October 2024, 4 hours ago.
This is the 16th video in the Getting Started with Rails 7 series. In this video Mike refactors the code written in the last video into a module called Visible that extends ActiveSupport::Concern. This module becomes the new home for the status-related code for both articles and comments. The two models both include the Visible module, and we can eliminate the previously duplicated code.

This video covers:
00:00:10 Introduction and recap of the last video
00:01:49 Create the Visible module and add the archived? instance method to it and include in Article and Comment models
00:04:07 Extend ActiveSupport::Concern and move the VALID_STATUSES constant to the module
00:05:39 Move the validation to an included block in Visible
00:07:49 Add tests for public_count concern class method
00:09:39 Add public_count class method to module
00:10:39 Add test for display of public articles to controller test, but make the count agree with the noun
00:12:37 Incorporate code from the guide, but it still fails "Our blog has one articles and counting!"
00:13:38 Use the pluralize helper to make the count and noun agree
00:15:00 Use a test-driven approach to add status to the article and comment forms
00:19:18 Test the changes in the application. Doesn't work as intended. Restart the server and it works.
00:23:35 Review, commit, and push code changes

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 16: Refactor Repeated Code Using ConcernsCodecast: Getting Started with Rails 7 23: Add Styles from CDNs to Improve DesignCodecast: 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 Specified

Codecast: Getting Started with Rails 7 16: Refactor Repeated Code Using Concerns @StatelessCode

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER