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.

πŸš€ Launches and discounts

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

Source: Amazon

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.

πŸ‘‰ 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:

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:

❀️ 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

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

🧰 Updates

🧰️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

🎧 Podcasts

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

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

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

πŸŽ₯ 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 πŸ†•

πŸ†• 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

πŸ†• 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

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

Reply

or to participate.