---
title: "Solidus as a rock"
publication: "Ruby Weekly"
issue: 549
published_at: "2021-04-22"
canonical_url: "https://rubyweekly.com/issues/549"
---

Plus more on variable pinning in Ruby. |        

#​549 — April 22, 2021 

[Read on the Web](https://rubyweekly.com/issues/549)   

Ruby Weekly 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/jqhmt35mws8qoyzyympz.jpg)](https://itnext.io/why-puma-workers-constantly-hung-and-how-we-fixed-by-discovering-the-bug-of-ruby-v2-5-8-and-v2-6-6-7fa0fd0a1958)  

[Why Our Puma Workers Constantly Hung, and How We Fixed It by Discovering a Bug of Ruby 2.5.8 and 2.6.6](https://itnext.io/why-puma-workers-constantly-hung-and-how-we-fixed-by-discovering-the-bug-of-ruby-v2-5-8-and-v2-6-6-7fa0fd0a1958) — This equally epically titled and epically long chase down the rabbit hole digs into the MRI crevices and tracks down a bug which was happily resolved in Ruby 2.7.2 and up. If you like chasing bugs from graphs down to the final resolution, this is for you. Issues around this area of Ruby have [been raised before](http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html). 

Yohei Yoshimuta   

[Bundler 2.2.3+ and the Deployment of Ruby Apps](https://prathamesh.tech/2021/04/18/bundler-2-2-3-and-deployment-of-ruby-apps/) — If you’re seeing weird bundler platform errors on deployment nowadays (for example: “`Your bundle only supports platforms "x86_64-darwin-20" but your local platform is x86_64-linux`” then you probably need to read this article. 

Prathamesh Sonpatki   [![\](https://copm.s3.amazonaws.com/78ba579f.png)](https://railsautoscale.com/?utm_source=rubyweekly) 

[On Heroku? Try Autoscaling the Rails Way](https://railsautoscale.com/?utm_source=rubyweekly) — Avoid app slowdowns and slash your Heroku bill using the only autoscaler designed for Heroku and Rails. We automate both web and worker dynos (Sidekiq, Resque, DJ, and more). Try it for free in [two clicks](https://elements.heroku.com/addons/rails-autoscale?utm_source=rubyweekly). 

Rails Autoscale sponsor   

[Solidus v3.0 Released: A Rails-Based Ecommerce Platform](https://solidus.io/blog/2021/04/20/solidus-v3-0.html) — Solidus is a [Spree](https://github.com/spree/spree) fork originally [created from a worry](https://solidus.io/blog/2015/10/28/future-of-spree.html) that Spree might not get updated anymore (although Spree is now fully alive). This 3.0 is a major level release due to a lot of removed deprecations (potential breakages for upgraders [covered here](https://github.com/solidusio/solidus/releases/tag/v3.0.0)). 

Solidus Team   

[How to Build An App, Get Acquired by GitHub, Buy An App Back From GitHub and Then Sell It Again](https://www.johnnunemaker.com/speakerdeck/) — If you’ve been in the Ruby world a long while, you might recall GitHub buying [Speaker Deck](https://speakerdeck.com/) from a company well known in the community. Here’s the whole story of how it went down. 

John Nunemaker     

Quick Bits 

- If you're a RubyMine _and_ Minitest user, their [improved Minitest support](https://blog.jetbrains.com/ruby/2021/04/improved-minitest-support/) will be of interest.
- The folks at Ruby Together have [a new update on their work.](https://rubytogether.org/news/2021/4/march-2021-monthly-update)
- The [DragonRuby Game Toolkit](https://dragonruby.itch.io/) seems to be having quite the sale (_as in it's free_) for a limited time, so if building a game in Ruby appeals to you, check it out.  

📘 Articles & Tutorials  

[A VCR + WebMock "Hello World" Tutorial](https://www.codewithjason.com/vcr-webmock-hello-world-tutorial/) — We all want our tests to be deterministic (no randomness and able to be repeated) and VCR and WebMock provide different ways to make HTTP requests to external systems predictable and repeatable. 

Jason Swett   

[How to Protect Access to Rack Apps Mounted in Rails](https://blog.arkency.com/common-authentication-for-mounted-rack-apps-in-rails/) — Whether its your own creations or things like the Sidekiq or Flipper interfaces, mounting Rack apps into Rails apps is pretty easy and here’s a look at how to add some _basic_ authentication. 

Paweł Pacana   

[Bitfields, Explained Like I'm 5](https://blog.rebased.pl/2021/04/06/eli5-bitfields.html) — A basic introduction to why an array of true/false values could come in handy. 

Krzysztof Zych   

[Free eBook: Efficient Search in Rails with Postgres](https://pganalyze.com/ebooks/efficient-search-in-rails-with-postgres?utm_source=RubyWeeklySecondary04222021) — Speed up a search query from seconds to milliseconds and learn about exact matches, trigrams, ILIKE, and full-text search. 

pganlayze sponsor   

[Ruby 3.1 to Allow Accumulation of `Enumerable#tally` Results](https://bigbinary.com/blog/ruby-3-1-accumulates-enumerable-tally-results) — It’s still a way off, but Ruby 3.1 will introduce an optional hash argument for `tally` that will add counts to an existing set of results. 

Ashik Salman   

[Listing the Contents of a Remote ZIP Archive, Without Downloading the Entire File](https://rhardih.io/2021/04/listing-the-contents-of-a-remote-zip-archive-without-downloading-the-entire-file/) — René compresses (HA!) lots of content about ZIP file structure and uncommon HTTP requests to fulfill this task. 

René Hansen   

[Rails 7 Enables Scoping to Apply to All Queries](https://blog.saeloun.com/2021/04/13/rails-enable-scoping-to-apply-to-all-queries.html) — This fixes an inconsistency with the `scoping` method between class and object queries. 

Apoorv Tiwari   

[The Future of Web Software Is HTML-over-WebSockets](https://alistapart.com/article/the-future-of-web-software-is-html-over-websockets/) — The HTML-over-Websockets continues having a moment. This post goes through the history of how we got here and why the new approach takes the best of that history to make the future. 

Matt E. Patterson   

[How and When to Use `case` Statements](https://docs.knapsackpro.com/2021/how-and-when-to-use-ruby-case-statements) — If you’re using multi-branch if-else if statements in your code, case statements can make them much cleaner. 

Shadi Rezek   

▶[Reducing Friction at the Authorization Layer with John Nunemaker](https://devchat.tv/ruby-rogues/ruby-494-reducing-friction-at-the-authorization-layer-with-john-nunemaker/) 
Ruby Rogues Podcast podcast   

[Rails 7 Adds `invert_where` Method to ActiveRecord](https://blog.saeloun.com/2021/04/21/rails-7-invert-where-method.html) 
Mayank Khanna    

Jobs  

[Help Enzyme get Quality Medical Tech Into the Hands of Patients](https://angel.co/company/enzymecorp/jobs/287059-full-stack-developer-senior) — As a Senior Full Stack Dev, help life science companies commercialize faster without compromising quality and patient care. Remote. 
Enzyme   

[Ruby on Rails Engineers Wanted - Sr & Intermediate Level](https://bit.ly/3mDSB9L) — We’re growing teams in Dublin/Riga/Toronto. Postgres, AWS, React, Redux. We’re one of the fastest growing SaaS companies globally. 
Workday   

[Find Ruby Jobs with Hired](https://hired.com/join/?utm_source=newsletter&utm_medium=sponsor&utm_campaign=%28b2c%29%28l-all%29%28r-all%29%28cooper-rubyweekly%29&utm_content=find-your-next-job) — Take 5 minutes to build your free profile & start getting interviews for your next job. Companies on Hired are actively hiring right now. 
Hired    

🛠 Code and Tools 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/zxmx5yeil1suzcmtnkvj.jpg)](https://github.com/rgeo/rgeo)  

[rgeo 2.3.0 Released: A Geospatial Data Library](https://github.com/rgeo/rgeo) — Implements the industry standard ‘OGC Simple Features Specification’ for representing objects like points, lines and polygons along with a set of operations. The [examples in the documentation](https://github.com/rgeo/rgeo/blob/master/doc/Examples.md) will give you an idea as to its use. 

Daniel Azuma and Tee Parham   

[FastRuby.io Guides You on How to Prepare Your Rails Application for an Upgrade](https://www.fastruby.io/blog/rails/upgrade/prepare-for-rails-upgrade.html?utm_source=rubyweekly) 

FastRuby.io sponsor   

[Reform 2.6.0: Form Objects Decoupled From Models](https://github.com/trailblazer/reform) — Gives you a form object with validations and nested setup of models. Framework-agnostic and doesn’t care about your database. 

TRAILBLAZER   

[wt_activerecord_index_spy: Report Missing Database Indexes](https://github.com/WeTransfer/wt_activerecord_index_spy) 
WeTransfer   

[Disposable: Decorators on Top of Your ORM Layer](https://github.com/apotonick/disposable) 
Nick Sutterer   

[OmniAuth Auth0 3.0: An OmniAuth Strategy to Login with Auth0](https://github.com/auth0/omniauth-auth0) 
Auth0   

[DNSimple Ruby Client 6.0](https://github.com/dnsimple/dnsimple-ruby) 
DNSimple   

[acts_as_list 1.0.4: An ActiveRecord Plugin for Managing Lists](https://github.com/brendon/acts_as_list) 
Brendon Muir       

💡**Tip of the Week** 

**Variable Pinning (Part 2 of 2)**   

In the _Tip of the Week_ [last week](https://rubyweekly.com/issues/548), we discussed how we could use variable pinning in pattern matching to compare a pattern to a local variable. Another use case for variable pinning in pattern matching is to compare a value within the same pattern. 

Let's say we want to make sure that both elements in an array are the same, but we don't care exactly what they are. We can use variable pinning again here. Let's take a look: 

```
case [1,1]
in [element,^element]
  "elements are the same: #{element}"
else
  "elements are different: #{element}"
end

=> elements are the same: 1
``` 

We assigned the first element to the variable `element`, and then used variable pinning (`^element`) to compare the second element to the first element. 

We can also confirm that if the two elements in the array weren't the same, we'd fall into the `else` case, with `element` sitll set to be the first element of the array: 

```
case [1,"different"]
in [element,^element]
  "elements are the same: #{element}"
else
  "elements are different: #{element}"
end

=> "elements are different: 1"
``` 

The [Ruby docs](https://ruby-doc.org/core-2.7.2/doc/syntax/pattern_matching_rdoc.html#label-Variable+pinning) give an interesting and practical use case for variable pinning. In the case from their example, we have a nested data structure where we have the school that `jane` is in, and the ids corresponding to each type of school. We want to find the `id` that matches her specific schoool type: 

```
jane = {school: 'high', schools:[
         {id: 1, level: 'middle'},
         {id: 2, level: 'high'}]
       }

case jane
# select the last school, level should match
in school:, schools: [*, {id:, level: ^school}] 
  "matched. school: #{id}"
else
  "not matched"
end

#=> "matched. school: 2"
``` 

Neat! We assigned the variable `school` to the value with the key `school`, and then pinned `school` to ensure it matched the level. This led us to the `id` we sought for `high` school, `2`. Variable pinning in pattern matching can be very helpful in these cases, as it allows us to match to values within the pattern itself.    

This week’s tip was written by [Jemma Issroff](https://twitter.com/jemmaissroff).          

Curated by [Peter Cooper](https://twitter.com/peterc), [Glenn Goodrich](https://twitter.com/ruprict) and [Cooperpress](https://cooperpress.com/). 

[Change your email address](https://rubyweekly.com/edit_subscription/*|UID|*) or[Stop getting this newsletter](https://rubyweekly.com/leave/*|UID|*) 

© Cooper Press Ltd · Fairfield Enterprise Centre, Louth, LN11 0LS, United Kingdom
