Spree Commerce 4.2 supports Ruby 3.0 and Rails 6.1
Spree Commerce 4.2 now supports Ruby 2.5, 2.6, 2.7, and, the recently released, 3.0. Rails 6.0 and 6.1 are supported out-of-the-box, so you don’t need to upgrade to Rails 6.1 straight away. You can first move to Spree Commerce 4.2 and later perform the Rails upgrade, minimizing the risk of any issues.
That might not mean much to those who are not well acquainted with the technical aspects of ecommerce development, but for developers, this opens up a new realm of possibilities.
Ruby on Rails – What’s the big deal?
Ruby on Rails is the most popular programming framework among top Y Combinator companies such as Airbnb, DoorDash, Instacart, Dropbox, Stripe, Shopify, Postmates, and more.
The Ruby on Rails open-source development is backed by Shopify and GitHub teams. Both of these websites are built – you’ve guessed it – using Ruby on Rails.
Airbnb, DoorDash, Instacart, and Postmates – 4 out of the top 5 marketplaces on the Andreessen Horowitz “Marketplace 100”, are built using Ruby on Rails.
Why choose Rails?
For developers, a huge benefit is that it liberates them from the monotonous aspects of coding, giving them more time to create other features for the app or website. There is also an active community on the Rails forum and Stack Overflow that they can turn to for assistance.
From a business point of view, there are numerous advantages that make Rails a versatile, practical framework: being free and open-source, with an extensive repository of free plugins available, it is highly cost-effective; it’s easy to modify existing code and add new functionalities to the website; having built-in safety features enabled by default and an active community that works to identify and patch vulnerabilities, it is secure; and when adequately optimized it has fast performance.
Now that Spree Commerce 4.2 supports Ruby 3.0 and Rails 6.1, developers and businessmen alike can rejoice at the inclusion of many performance-enhancing updates!
Rails 6.1 Features
Rails 6.1 includes updates to many of its existing features, as well as, a number of brand new features such as:
- Per-database Connection Switching – Rails 6.1 provides you with the ability to switch connections per-database. In 6.0 if you switched to the reading role then all database connections also switched to the reading role. Now in 6.1 if you set legacy_connection_handling to false in your configuration, Rails will allow you to switch connections for a single database by calling connected_to on the corresponding abstract class.
- Horizontal Sharding – Rails 6.0 provided the ability to functionally partition (multiple partitions, different schemas) your database but wasn’t able to support horizontal sharding (same schema, multiple partitions). Rails wasn’t able to support horizontal sharding because models in Active Record could only have one connection per-role, per-class. This is now fixed and horizontal sharding with Rails is available.
- Strict Loading Associations – allows you to ensure that all your associations are loaded eagerly and stop N+1’s before they happen.
- Delegated Types – an alternative to single-table inheritance. This is helpful for representing class hierarchies allowing the superclass to be a concrete class that is represented by its own table. Each subclass has its own table for additional attributes.
- Destroy Associations Async – adds the ability for applications to destroy associations in a background job. This can help you avoid timeouts and other performance issues in your application when destroying data.
Ruby 3.0 Features
Using the Optcarrot benchmark, which measures single thread performance based on the NES’s game emulation workload, Ruby 3.0 performed 3x faster than Ruby 2.0! Below are some of the other improvements and features included in the latest major release:
- MJIT – performance improvements in limited workloads, such as games, AI, or applications that spend most of the time calling a few methods many times.
- Concurrency:
- Ractor – an experimental feature, Ractor is an Actor-model concurrent abstraction designed to provide a parallel execution feature without thread-safety concerns. Make multiple Ractors and run them in parallel.
- Fiber Scheduler – Fiber#scheduler has been introduced for intercepting blocking operations. This allows for lightweight concurrency without changing existing code.
- Static Analysis:
- RBS – RBS is a language to describe the types of Ruby programs. Type checkers, including TypeProf and other tools supporting RBS, will understand Ruby programs much better with RBS definitions.
- TypeProf – TypeProf is a type analysis tool bundled in the Ruby package that currently serves as a kind of type inference. It reads plain Ruby code, analyzes what methods are defined and how they are used, and generates a prototype of type signature in RBS format.