- Short Ruby Newsletter
- Posts
- Short Ruby Newsletter - edition 111
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
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
π Josef Strzibny announced the second edition of Kamal Handbook
Source: @strzibnyj
source: @SocketSecurity
π Jelly: A Better Shared Inbox is open for business
π Events
π Brighton Ruby announced the tickets are live for BrightonRuby:
Source: @brightonruby
π Ruby Conf India shared RubyConf India
Source: @rubyconfindia
π 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:
Source: [email protected]
οΈπ» 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):
Source: @MichaelDChaney (read on Threadreader)
οΈπ» Nate Berkopec shared a code sample to Test your seed file
Source: @nateberkopec
# 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:
Source: @cjavilla.bsky.social
π» Stephen Margheim shared an advice about testing ActiveJob:
Source: @fractaledmind.bsky.social
π Thinking about Code Design
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:
Source: @nateberkopec
οΈποΈ 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
Source: @GregMolnar (read on Threadereader)
Source: @strzibnyj (read on Threadreader)
Source: @mhenrixon (read on Threadreader)
Source: @ikristoph (read on Threadreader)
There is also a followup on this story:
Source: @rameerez (read on Threadreader)
Source: @robzolkos (read on Threadreader)
On a similar thread there is also a big Reddit discussion (118 comments so far). Here are two comments:
Source: SnooLobsters6044
Source: Weird_Suggestion
π 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:
Source: @AmandaBPerino
π‘ 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:
Source: [email protected]
π‘ Sean Collins asked about where to find contracting jobs for Ruby that does not involve Rails:
Source: [email protected]
β€οΈ 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:
Source: @sean_j_roberts
β€οΈ Josh Brown shared a PR about Replace custom stock search select with Hotwire combobox
Source: @JoshAntBrown
β€οΈ 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.
Source: https://github.com/renuo/moirai
π 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!
Source: rubyonrails.org
π§°οΈ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
π 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
Reply