Short Ruby Newsletter - edition 111

The one with 2 book launches, tickets available for BrightonRuby, a new release of ruby/json making JSON.dump twice faster

In partnership with

Table of Contents

Try the internet’s easiest File API

Tired of spending hours setting up file management systems? Pinata’s File API makes it effortless. With simple integration, you can add file uploads and retrieval to your app in minutes, allowing you to focus on building features instead of wasting time on unnecessary configurations. Our API provides fast, secure, and scalable file management without the hassle of maintaining infrastructure.

Try it now!

πŸš€ Launches and discounts

πŸš€Β Jason Swett launched their new book Professional Rails Testing

Source: Amazon

πŸš€Β Josef Strzibny announced the second edition of Kamal Handbook

Source: @strzibnyj

πŸš€Β Socket now supports #Ruby in beta!

πŸš€Β Jelly: A Better Shared InboxΒ is open for business

πŸ“… Events

πŸ“…Β Brighton Ruby announced the tickets are live for BrightonRuby:

πŸ“…Β Ruby Conf India shared RubyConf India

πŸ“…Β Ruby Conf announced a series of speakers, I am adding here one of the announcements:

Source: @rubyconf

πŸ“…Β Tropical.Rb announced a series of speakers confirmed for the conference and will have the tickets on sale on 30 October

Source: @tropical_rb

πŸ“… Check RubyConferences.orgΒ for meetups or conferences happening this week and don’t forget to submit yours if you are organising one.

Why struggle with file uploads? Pinata’s File API is your fix

Simplify your development workflow with Pinata’s File API. Add file uploads and retrieval to your app in minutes, without the need for complicated configurations. Pinata provides simple file management so you can focus on creating great features.

Build now!

πŸ‘‰ All about Code and Ruby

πŸ‘‰ There seems to be some people from the Ruby community creating accounts on BlueSky and starting posting there. In case you think to join, Joshua Wood created a Starter Pack with Ruby and Ruby on Rails people:

πŸ’» Code Samples

πŸ’» Dave Copeland shared a code sample about combining rightwards assignment with then:

οΈπŸ’» Rob Lacey shared a code sample about removing memoization when using memery: A gem for memoization in Ruby

Source: @braindeaf

οΈοΈπŸ’» Michael Chaney shared about hash rocket syntax (here is just a part of the big post shared my Michael - read it full on Threadreader):

οΈπŸ’» Nate Berkopec shared a code sample to Test your seed file

# Source: https://gist.github.com/nateberkopec/46882c217140e46f670085f767cbe748

require "test_helper"

class SeedTest < ActiveSupport::TestCase
  def total_count
    ActiveRecord::Base.connection.execute(
      "SELECT SUM((SELECT COUNT(*) FROM #{ActiveRecord::Base.connection.quote_table_name(t)})) FROM (SELECT tablename as t FROM pg_tables WHERE schemaname = 'public') tabs"
    ).first["sum"].to_i
  end

  def test_seeding_successfully
    ActiveRecord::Base.connection.execute(
      "TRUNCATE TABLE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY CASCADE"
    )
    assert_difference "total_count", 1000..Float::INFINITY do
      Rails.application.load_seed
    end
  end

  def test_idempotent
    Rails.application.load_seed
    assert_no_difference "total_count" do
      Rails.application.load_seed
    end
  end
end

R.J. Robinson added a version for RSpec:

# Source: https://gist.github.com/nateberkopec/46882c217140e46f670085f767cbe748?permalink_comment_id=5253019#gistcomment-5253019
require 'rails_helper'

RSpec.describe 'Database Seeding' do
  def total_count
    ActiveRecord::Base.connection.execute(
      "SELECT SUM((SELECT COUNT(*) FROM #{ActiveRecord::Base.connection.quote_table_name(t)})) FROM (SELECT tablename as t FROM pg_tables WHERE schemaname = 'public') tabs"
    ).first['sum'].to_i
  end

  before(:each) do
    ActiveRecord::Base.connection.execute(
      "TRUNCATE TABLE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY CASCADE"
    )
  end

  describe 'Seeding the database' do
    it 'seeds successfully' do
      expect {
        Rails.application.load_seed
      }.to change { total_count }.by_at_least(1000)
    end

    it 'is idempotent' do
      Rails.application.load_seed # Initial seeding

      expect {
        Rails.application.load_seed
      }.not_to change { total_count }
    end
  end
end

πŸ’» Jon Yongfook’s fav feature of rails is the before_action callback

source: @yongfook

οΈπŸ’» ️Ruby Cademy shared tips that helps you make better use of rails console

source: @RubyCademy

Here’s how to clear your terminal screen when running rails console!

source: @RubyCademy

The up_only method in ActiveRecord allows you to create migrations that apply changes to the database schema without the option to roll them back, which can be particularly useful for certain irreversible operations

source: @RubyCademy

Here’s an example of Static Model Pattern in rails

source: @RubyCademy

πŸ’» ️Victor Cobos shared a template for Custom Error Pages | Rails Bytes

source: @elalemanyo

οΈπŸ’» Dennis Paagman shared a tip for triggering a Turbo preload

Source: @djfpaagman

οΈπŸ’» Christopher Winslett shared about using Kamal 2 with for a preview host:

Source: @winsletts

πŸ’» CJ Avilla shared a code sample showing how to use retry to wait for a toast:

πŸ’» Stephen Margheim shared an advice about testing ActiveJob:

πŸ“ Thinking about Code Design

οΈπŸ“Β Jp Camara shared a benchmark of Ruby/Falcon vs Bun bench.txt

Source: @jpcamara

πŸ“ ️Michael Chaney warns us about a potential pitfall in Rails regarding the normalizes feature

οΈπŸ“Β Jean Boussier shared about working on a blog post about the new out of band GC:

Source: @_byroot

οΈπŸ“Β Nate Berkopec shared about Minitest:

οΈπŸ“οΈ Lukasz Reszke shares a couple of drawbacks he noticed on keeping logic outside model

source: @lreszke

πŸ“Last week there was a big discussion about Kamal that started with Javi Ramirez sharing about Kamal a couple of point that they think will make Kamal in danger of not being continued. Here is just the first 2 points (out of 14 points Javi shared - read it all on Threadreader). While reading the pros and cons I ask you to please be kind and appreciate people having an open public debate sharing their personal experiences.Β 

Source: @rameerez (read on Threadreader)

There were a couple of replies. Here are some parts of some of them (but you should read them on their full content):

Source: @mediafinger

Source: @strzibnyj

There is also a followup on this story:

Source: @rameerez (read on Threadreader)

On a similar thread there is also a big Reddit discussion (118 comments so far). Here are two comments:

πŸ“Β Ross Kaffenberger shared a thread about Sending Web Push Notifications from Rails

Source: @rossta

πŸ’‘οΈ Andrea Rocca asked about switching Active Storage service providers:

Source: @ilrock__

Here are some answers:

πŸ’‘Around code (news, findings, books, and more - all about Ruby)

πŸ’‘Β Amanda Brooke Perino shared about hiring in Rails:

πŸ’‘Β Stan Lo shared that Ruby documentation is now using a red theme:

Source: @_st0012

πŸ’‘Β Ben Ubois shared stats about their usage of Sidekiq at Feedbin:

πŸ’‘Β Sean Collins asked about where to find contracting jobs for Ruby that does not involve Rails:

❀️ Why Choose Ruby and Rails

❀️ Haseeb Annadamban shares how easy it is to work on a codebase that does not deviate from Rails.

source: @Haseebeqx

❀️ Sean Roberts shared about using Rails + Turbo + Phlex + AlpineJS:

❀️ Josh Brown shared a PR about Replace custom stock search select with Hotwire combobox

❀️ Jonathan Markwell shared about building with Bullet Train or Jumpstart and Avo:

Source: @jot

❀️ Mike Mc Quaid shared about Ruby being great for moving fast:

Source: @MikeMcQuaid

❀️ Jon Yongfook shared about using Rails in the center of everything:

Source: @yongfook

🧰 Gems, Libraries, Tools and Updates

πŸ†• New Gems and Repos

πŸ†•Β Alessandro Rodi announced a new gem moirai: Let the world be translated, one typo at a time.

πŸ†•Β Nate Berkopec announced a new gem ids_must_be_indexed: A GitHub Action to ensure all Rails application foreign key columns are indexed

πŸ†•Β Josef Strzibny announced a new open source project strzibny/asciidoc-book-template: Simple technical book template

πŸ†•Jerome Dalbert published a new gem rubocop-obsession - RuboCop extension focused on higher-level concepts, like checking that code reads from top to bottom

πŸ†•Β RailsDesigner published a new tool Rails Development Tool

🧰 Updates

🧰 Ruby On Rails announced a new version of Ruby on Rails — Rails Versions 6.1.7.10, 7.0.8.6, 7.1.4.2, and 7.2.1.2 have been released!

🧰️Jean Boussier announced a new release for Ruby JSON

Source: @_byroot

He shared some benchmarks in the PR:

🧰 Joel Drapper announced a new version of Literal

Source: @joeldrapper

🧰 Thoughtbot announced a new version of Release 6.4.4 · thoughtbot/factory_bot_rails

🀝 Lukasz Reszke shared a tip on how to use git’s bisect feature to find the change that caused the bug faster

source: @lreszke

🀝 Jorge Manrubia emphasizes the importance of accessibility in web development

source: @jorgemanru

 🀝 Tony Dinh tells us how to build a successful product

source: @tdinh_me

He also mentions what he learned about security from his early days of being a dev

source: @tdinh_me

🀝 Allen Holub speaks about how object-oriented programming is often misunderstood and misapplied

source: @allenholub

🀝 Kyrylo Silin tells us why we need underscore in target=”_blank” to open a link in a new tab

source: @kyrylosilin

🀝 Simon Chiu shares the most overlooked things you can do to build a product

source: @geetfun

🀝 Jason Swett shares his thoughts on third party libraries

source: @JasonSwett

More content: πŸ“š πŸ—ž 🎧 πŸŽ₯ ✍🏾

πŸ‘‰ Vladimir Dementyev shared their slides from Kaigi On Rails about Rails Way or the highway

πŸ—ž Newsletters

πŸ—ž Ruby On Rails published a new edition about Ruby on Rails — Active Job config enqueue_after_transaction_commit has been deprecated

πŸ—ž Hotwire Weekly published a new edition about Week 43 - Turbo Broadcasting without Redis, Web Push from Rails, and more!

πŸ—ž Awesome Ruby Newsletter published a new article about Issue 440 - hide_const, the RSpec helper that I had never used before

🎧 Podcasts

🎧 Patrick O Shaughnessy published a new podcast Building Islands of Innovation - Colossus

🎧 Jp Boily published a new podcast FounderQuest | Selling Metrics Watch with JP Boily

🎧 Ode To Rails Conf published a new podcast about Drew Bragg

🎧 Code And The Coding Coders Who Code It published a new episode Episode 42 - Cody Norman

🎧 The Ruby On Rails Podcast published a episode about Episode 526: Rails World with Robby Russell

πŸ“½οΈ πŸŽ₯ Videos

πŸŽ₯ Yaroslav Shmarov published a new video SupeRails | Sentiment Analysis: No AI, just math | SupeRails #206

πŸŽ₯ Brad Gessler published a new video about how to integrate with Stripe as little as possible to collect payment for Terminalwire

πŸŽ₯ Chris Oliver published a new video about How to Configure Multiple Databases with Rails

πŸŽ₯ Thoughtbot published a new video Mid-day talk

πŸŽ₯ Irina Nazarova announced videso from the last SF Bay Area Ruby Meetup are live

πŸŽ₯ Adam McCrea a new video about Migrating an 8-yr-old Rails app from Heroku to Render

✍🏾 Articles

What’s new πŸ†•

πŸ†• Ruby Central published a new article about Announcing Ruby Central's Partnership with Fastly: Enhancing Performance & Stability for Open Source Tools

πŸ†• William Kennedy published a new article about Hotwire Native iOS Part 1 | William Kennedy

πŸ†• Josef Strzibny published a new article A closer look at Rails force_ssl and assume_ssl

πŸ†• Camillo Visini published a new article about Streamlining Your Rails 8 App: Migrating from Postgres to SQLite

πŸ†• Rodrigo Rosenfeld Rosas published an article about Why is your Rails app boot slow?Β and about Creating web app monoliths that boot instantly with Ruby

Β πŸ†• Onur ΓΆzer published a new article about CSRF, CORS, and HTTP Security headers Demystified

πŸ†• Josef Strzibny published a new article about Understanding Kamal proxy roles

πŸ†• Nithin Bekal published an article about Rails 8 authentication generator

πŸ†• Rails Designer published an article about How do Turbo Streams Work (behind the scenes)

πŸ†• Mike McQuaid published an article about Ruby on (Guard)Rails

πŸ†• Jeffery Morhous published an article about The ultimate guide to Sidekiq scheduled jobs

πŸ†• HΓΉng LΓͺ published an article about Ruby Fiber Scheduler and Async

πŸ†•Prasanth Chaduvula published a new article about Rails 7.1 Adds Adapter Option To Disallow Foreign KeysΒ and about Rails 7.1 Allows Subscribing To ActiveRecord Transaction Events For Instrumentation.

πŸ†• Jon Sully published a new article about Propshaft Pt. 3: Assets Importmaps

πŸ†• Ross Kaffenberger published an article about Sending Web Push Notifications from Rails

πŸ†• Ryan Bigg published a new article about Ruby Retreat 2024

πŸ†• Joey Wang published a new article about Deep Dive into Ruby Internals: From Rails Caching to C-Level Object IDs 2024-10-27

How-TOs πŸ“

πŸ“ Exequiel Rozas published an article about S3 uploads with Active Storage guide

πŸ“ Svyatoslav Kryukov published a new article about Integrating shadcn/ui | Inertia Rails

πŸ“ Lucas M. published an article about Adding a Rubocop config to an old repository | step-by-step guide

πŸ“ Artem Yegorov published an article about Using meta-programming in Ruby to build a REST API from a JSON fileΒ and about How to continue to use Rails.application.secrets in Rails 7.2

Joey Wang published a new article about How to Debug Docker Image Builds, Docker Secrets Management: Security Deep Dive and Implementation GuideΒ and about Mastering Three-Way Merge with Neovim, Fugitive, and Delta

All issues