Weekly Digest #4 : Rails 7 pagination with Kaminari tutorial
Curated and handpicked Ruby on Rails blogs.
Introduction
In this issue, we have picked 10 interesting articles published last week that are worth reading. These articles cover topics such as Rails 7 pagination, ActiveRecord association, VCR gem, RuboCop, Fragment caching etc. Consider subscribing, liking, and sharing it.
Code-Along & build an advanced e-learning platform. Biggest, Most complete Ruby on Rails 6 course. ( Affiliated )
Ruby on Rails: Learn 25+ gems and build a Startup MVP
4.5 ⭐ | 5k students
1. Rails 7 pagination with Kaminari tutorial
This article addresses the issue of displaying large amounts of data in a single page in a Rails application, which can lead to performance degradation. The author emphasizes the negative impact on both the front-end and back-end, citing increased database reads, memory allocation, and longer response times.
2. 10 Best Practices Active Record Associations in Ruby on Rails
Active Record associations in Ruby on Rails facilitate the expression of model relationships, streamlining the handling of related data through an intuitive API. Best practices for the effective utilization of Active Record associations are outlined in this article.
3. Speed Up Your Tests Using VCR Gem in Ruby
The article introduces the VCR gem in Ruby as a solution to speed up tests involving HTTP API requests. The author describes a scenario of working on a client project with numerous API calls that require extensive testing and data manipulation. The conventional testing approach, making actual API calls for each test, becomes slow and cumbersome.
Learn to make innovative web apps with Ruby on Rails and unleash your creativity ( Affiliated )
The Complete Ruby on Rails Developer Course
Bestseller | 4.4 ⭐ | 100k+ students
4. Playing Sounds in Rails with the Audio API
The article explores how Campfire, a platform allowing users to play sounds in a Rails application using the Audio API, accomplishes this feature. The author dissects the process by examining the source code and providing insights into the implementation, involving various aspects of Rails and Hotwire.
5. Need for Speed: Using RuboCop with Prism
The article discusses the introduction of Prism, a modern and highly efficient Ruby parser aiming to replace existing parsers, including the one used by RuboCop. The author, the creator of RuboCop, highlights the criticism the tool faced due to its parser's perceived slowness. Prism is presented as a potential solution, offering notable speed improvements.
6. Rails 7.1 Introduces ActiveRecord Regroup Method
Rails 7.1 has introduced new ActiveRecord::QueryMethods called regroup and regroup! to simplify the resetting of previously set group statements in database queries. ActiveRecord::QueryMethods are utilized in Rails to construct and execute database queries, and the group method is employed for grouping operations, allowing data retrieval based on specific columns with the generation of a SQL query featuring a GROUP BY clause.
Advance your SQL skills by practicing it ( Affiliated )
Checkout analystbuilder platform for more
Use discount code: ABNEW20OFF for 20% off
7. A decent VS Code + Ruby on Rails setup
The article guides users in setting up Visual Studio Code (VS Code) as a Ruby on Rails editor, aiming to simplify the process of selecting and configuring extensions. The author shares a curated collection of core extensions grouped into four categories: language servers, other Language Server Protocols (LSPs), formatters/linters, and ERB formatters and language tools. An extension pack is provided for users to conveniently install all recommended extensions at once.
8. Spaghetti Model Part 4: Safely Remove ActiveRecord Associations and Scopes
The article emphasizes the potential pitfalls of ActiveRecord associations, particularly the ease with which objects can traverse domain boundaries, leading to Law of Demeter violations. To tackle this issue, a strategic five-step approach is proposed.
9. Fragment Caching in Ruby on Rails
Ruby on Rails prioritizes a "convention over configuration" approach in web development, simplifying the process and emphasizing convention-based design. Fragment caching, a key strategy within Rails, selectively caches parts of web pages rather than entire pages or rendering actions, optimizing performance.
10. Rails 7.1 Allows ActiveRecord::Relation#explain To Accept Options
In Rails 7.1, ActiveRecord::Relation#explain now accepts additional options, enhancing the analysis of query performance. The explain method, which runs EXPLAIN on the query triggered by the relation, provides insights into SQL query execution plans. Previously, it displayed results in a format imitating database shell outputs.
Learn to program in the Ruby programming language. ( Affiliated )
Bestseller | Rating: 4.8⭐ /5 (6k ratings) | 78k students
That’s a wrap for this week. If you have any feedback, requests, or improvements for this newsletter consider commenting so that we can work on improvements for the next one.