Image of Lucian Ghinda writing for notes.ghinda.com
Short posts mostly about Ruby and Ruby on Rails. You can find me at : Linkedin, Mastodon, Twitter, Bluesky or for longer posts at allaboutcoding.ghinda.com. Check goodenoughtesting.com if you want to learn to write fewer tests and cover more features. 
Subscribe via RSS here

Sleep can improve your productivity

We probably all know this, but let me remind you—and mostly myself—that getting a good night's sleep is one of the simplest ways to boost productivity.

Add a 30-minute walk in the morning, and you'll likely see a 3.14x or even 7.5x increase, at least. 

You decide!

When posting on Bluesky or Mastodon use hashtags

A gentle reminder: please use #Ruby or #Rails when posting about Ruby or Ruby on Rails on Bluesky and Mastodon.

It helps with content discovery, and the search works much better, IMO when looking for hashtags.

Include Hashtags

Let me add another thought: 

  • I recommend to tag with \#Ruby and \#Rails because Rails uses Ruby :) 
  • There should not be a need to say this out loud, but I discovered a lot of content tagged only with Rails, which says something about how massive Rails is in the Ruby world.

I am approaching this from the perspective of someone who, let's say, just found out about Ruby on Rails and tries to search on Bluesky or Mastodon.

If they search for #Ruby, they should also see #Rails content and get inspired about what they could achieve with it.


Why do I talk here about Bluesky and Mastodon? 
For example, Twitter or Linkedin have their own algorithm to push content, and I am not sure hashtags are any part of it. It seems to me that what matters there is the virality of the post. But if you post on Linkedin or Twitter please do add hash tags there too. 

PS: It works for other topics, too!

How grape-entity works

Someone asked on Reddit a question like:

> Can anyone provide me an informative article on how grape-entity works?

I don't know or not able to find an article that describes how it works.

Whenever I use it, and I have some doubts, I try to read the source code. 

You can start from here:
https://github.com/ruby-grape/grape-entity/blob/master/lib/grape_entity/entity.rb

But all the files in this folder https://github.com/ruby-grape/grape-entity/tree/master/lib/grape_entity are relatively easy to read.

In case you feel like having questions like "How did the entity got that value or what is the source of that value" I would recommend looking into the delegators https://github.com/ruby-grape/grape-entity/tree/master/lib/grape_entity/delegator

Consider carefully when deciding to create an array column in Rails

Think carefully about whether I truly need an array column in Rails or if it's more effective to create it as JSON from the start.

Sooner rather than later, I would like to enrich that column and add some extra information. 

Which will create the need for a 3-stage migration:

  • Add new column while keeping the old one 
  • Execute data migration by generating the new structure in the new column
  • Change the code to use the new column
  • Drop the original column

Before deciding, I should clarify the reasons this will always be an array instead of just assuming it is one. And if there are no good reasons for it maybe it should be a JSON/JSONB column from the start. 

Of course, could be that this should just be a nested model -> but that is a decision to be discussed in another post :)

Twitter transitioned to Scala to continue writing beautiful code

I found this quote in this article about Twitter moving to Scala:

> But he also prefers Scala because it's, well, beautiful. "It's a fuzzy thing. But we like writing beautiful code, code that you're proud of, code that you can show to non-programmers and they get it."

About Scala and writing beautiful code

They chose Scala because they wanted to write "beautiful code." 
I think I can say that Ruby influenced this decision in more ways than one.

Short Ruby Newsletter - Highlights from edition 117

🚀 Launches

  • Stanislav Katkov launched the website for poshtui.com
  • Lindsey Christensen launched the Hotwire Essentials
  • Sandi Metz announced a 40% discount for their books until 13 December
  • Martin Sojka launched codesnips.io
  • Andrey Eremin launched a new course Ruby on Types: Static Typing with Ruby and Ruby on Rails
  • Josef Strzibny announced that testdrivingrails.com - 1st edition is out

📅 Events:

  • RoRvsWild shared a map from Ruby meetups in Europe
  • Check RubyConferences.org/meetups as there 26 meetups this week only around the world
  • Ruby Central invites Ruby meetup organizers to apply for a grant
  • Balticruby announced CFP is open at papercall.io/balticruby25

👉 All about Code and Ruby

Ruby On Rails announced that The Rails Foundation welcomes 1Password as Core member.

There are a lot of code samples included; here are just some of them:

  • Drew Bragg shared a code sample about DATA constant in a Ruby file
  • Xavier Noria shared that Ruby already has “pipe operator" and that is the dot
  • Akash Manohar shared a tip about enabling debugging for Stimulus:
  • Prabin Poudel shared a code sample about accessing a helper method
  • Joel Drapper shared a code sample about defining a / method to lookup a record by using a Base64 id
  • Jamie Schembri shared a code sample about using StringInquirer from ActiveSupport
  • Joël Quenneville shared a code sample showing how converting to UTC changes a time value
  • Nate Berkopec shared a code sample about how IO/CPU interact with the GVL
    And there are so many more code samples. This edition is packed with interesting code samples, discussions about code design, and inspiration around code.

🧰 Gems, Libraries, Tools and Updates

  • Vladimir Dementyev published a new gem called wasmify-rails - Tools and extensions to pack and run Rails apps on Wasm
  • Sam Ruby announced a new gem called fly-atc - A SaaS toolkit for mutli-tenant production deployments with zero-config streaming backups
  • Alex Denisov shared their work on lightstorm: Minimalistic ahead-of-time Ruby compiler

You will also find updates on their projects or libraries from Rosa, who announced the 1.0 version of Mission Control Jobs, Avo, who announced version 3.15.0 with huge improvements, Bozhidar Batsov, who announced an update about Rubocop v1.69.1, Nate Hopkins, who announced an update about LocalBus v.0.3.0, and many more gem updates.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at https://newsletter.shortruby.com/p/edition-117


Using shoutouts.page to embed a link to my workshops

Maybe this would be a great time to share more buildinpublic or experiment with how this works.

This morning, I added a footer to the booklet about testing for developers Writebook from 37 Signals, and I used the that are using https://shoutouts.page for this.

Here is how it looks like on the main website https://booklet.goodenoughtesting.com

Displaying the embeded shoutout

I created a small snippet on shoutouts.page by Vincent Ritter 

I chose this because, once included, any changes to the text or image will automatically update everywhere it's embedded

Here is how it looks like to create the shoutout:

The form for creating the shoutout

I then embedded this to two places: 

  1. booklet.goodenoughtesting.com
  2. notes.ghinda.com - this blog where you read this content

I could not make it work for the Hashnode where I have the longer form articles: allaboutcoding.ghinda.com. Not sure why and I did not had time to debug. 

The entire process took me about 30 minutes at most, considering I already had the Open Graph image from a post I published about the #GoodEnoughTesting workshop some time ago.

Before using Shoutout, I manually added information about where to find me online at the end of each blog post. This process was time-consuming, and if I wanted to make changes, I had to edit multiple posts in various places.

Two recommendations if you want to start a blog

If you're planning to start a blog or just publish some notes, may I suggest two projects launched by two very lovely Ruby developers?

Both are easy to start with, simple to set up, and offer just enough options to get you going without the need to configure many things.

1️⃣ scribbles.page by Vincent Ritter 

I am using this one for the current notes blog, where I post shorter form article and quicker notes.

scribbles.page

2️⃣ pagecord.com by Olly Headey

See an example of how it looks https://pagecord.com/pagecord

I am looking for a reason to use it :) even if I already have 2-3 blogs already

Pagecord is also open source at https://github.com/lylo/pagecord

pagecord.com


Here is a short audio where I share why I think you should start a blog or share more your knowledge: 

https://podcast.shortruby.com/2417631/episodes/16192809-sharing-your-knowledge-as-a-path-to-mastery


 

Short Ruby Newsletter - edition 116

🚀 Launches


📅 Events:


👉 All about Code and Ruby

There a lot of code samples included; here are just some of them:

  • Jorge Manrubia shared they will announce a surprise for Hotwire before Christmas, Tobi Lutke shared the stats from Shopify during Black Friday
  • Postmodern asked about array.fetch(index,0) versus array[index] || 0 and there was an interesting discussion about it
  • RoRvsWild shared a code sample about avoiding returning from model’s method
  • Nate Berkopec shared the latency numbers every Ruby on Rails dev should know
  • Matt Swanson shared a code sample about using code design to guide developers to make the correct decisions
  • JP Camara shared a thread about calculating the largest known prime number by using the latest PR about "Do not round a**b to infinity by mame · Pull Request \#12033" that will be part of Ruby 3.4
  • Bozhidar Batsov shared a code sample about touching a file in Ruby by using File.open(path, ‘a’) {}
  • Jeremy Smith shared about Stimulus pain points and proposed a solution
  • Gregory Brown shared a a code sample about an inline template experiment
  • Ruby Cademy shared a code sample about using ActiveSupport::BacktraceCleaner
    And there are many more code samples you can browse and have inspiration while coding this week.

Remember to read ️ 📐Thinking about Code where Remi Mercier asked about how to trigger a bunch of turbo streams right after the initial request and got a couple of replies, Noel Rappin started a discussion about treating application.rb and environments files immutable, Benjamín Silva H. asked about if the loops benchmark can be optimised and read the replies.

Inside 💡Around code section, Tropical.Rb asked absout recommendations for people just getting started with Rails and there are some nice replies there about it.

🧰 Gems, Libraries, Tools and Updates

  • Yaroslav Shmarov announced a new gem hotwire_native_rails - Hotwire Native generator for Rails applications
  • Harry Lascelles announced a new gem dememoize - A rubygem to remove memoized values (instance variables) for easier testing
  • Marcus Almeida announced a new gem curlify - The gem convert ruby requests(net/http) into curl command
  • Samuel Williams announced a new project async-discord - combining async-ollama and async-discord
  • Svyatoslav Kryukov announced a new demo repo skryukov/inertia_rails_svelte5_ssr
  • Nemo published a new gem jekyll-sqlite - A Jekyll plugin to use SQLite databases as a data source
  • Adrien Siami announced a new gem hyperactiveform: Simple form objects for Rails
  • Onyx announced a new gem for Pinata library pinata-ruby
    There are also interesting updates from various gems and libraries.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at https://newsletter.shortruby.com/p/edition-116

Reminder to write articles about Ruby to have better LLM suggestions

Reminder to publish article about Ruby

This is a weekly reminder that if you want better suggestions for Ruby and Rails projects using LLMs (Large Language Models), you should consider writing more articles (not generated by LLMs) about how you believe idiomatic Ruby and Rails code should be written or showing modern Ruby and Rails code. 

Aim to produce content for beginners, intermediates, seniors, and experts. The more you publish online, the better!

Remember that current AIs are LLMs, so to receive improved suggestions for Ruby, you need to train them with more knowledge.

Additionally, there is a lot of outdated Ruby content that requires refreshing. One way to identify this content is to browse Stack Overflow for older questions and write articles on how you would solve those questions using Ruby 3.3+ and Rails 8.

Here are two queries you can use for reference:

  • https://stackoverflow.com/questions/tagged/ruby?sort=MostFrequent&edited=true
    - https://stackoverflow.com/questions/tagged/rails?sort=MostFrequent&edited=true

Take a look at those questions from 2011. Please write an article providing a fresh answer for them.

When Neovim does not know the Ruby version

If you are using:
- MacOS
- Neovim configured with Lua
- a Ruby version manager (for example chruby)
- zsh 

Then in case you cannot install for example RubyLSP because after installing a new version of Ruby it seems like Neovim does not recognize anymore the global Ruby version set and defaults to the system Ruby (which is ruby 2.6.x) you can fix this by adding the following to your Lua Neovim config:

vim.opt.shell = "zsh"
How to fix when Neovim loads system's Ruby version

Short Ruby Newsletter - edition 115 highlights


🚀 Launches

  • Kuba Suder launched sdk.blue - a collection of all SDKs about Bluesky
  • Brian Casel launched Instrumental.dev - Rails UI Components to Build Better Products, Faster
  • Zack Gilbert launched susanssudoku.com - a simple in browser Sudoku
  • Check the Short Ruby Newsletter Deals for Ruby Developers page

📅 Events:

  • Visuality announced the Ruby Community Conference - Winter 2025, with Rosa Gutierrez being the first speaker
  • Paul Campbell shared they are thinking to organise a Ruby conference in Ireland
  • Balkan Ruby announced tickets are on sale for balkanruby.com
  • Check rubyconferences.org to see upcoming conferences announced and rubyconferences.org/meetups to see all meetups that will happen this week

👉 All about Code and Ruby
There are a lot of code samples included; here are just some of them:

  • Xavier Noria shared that alias_method does not give a polymorphic alias
  • Henrik Nyh shared a code sample about combining uniq and sole to check object classes
  • Ross Kaffenberger shared a code sample about using Rails excluding and with
  • Kerrick Long shared an interesting code sample about using the under-the-covers technique shared last week by Victor Shepelev in their article
  • Ruby Cademy shared about using pick and ids instead of pluck for getting the attribute of the first element or the ids
  • Saeloun shared about generating controllers in Rails with --parent option
    And there are a lot more code sample to inspire you while coding.

Remember to read ️ 📐Thinking about Code where Russ Olsen asked about what's new in Ruby in the last 5 years and got a lot of replies, where Brandon Weaver shared about modularity failing because it is seen as a technical issue and other interesting discussions.

🧰 Gems, Libraries, Tools and Updates

  • Chris Oliver announced a new gem black_friday: Black Friday sales in your Rails apps
  • Samuel Williams announced a new gem socketry/async-cable
  • Vladimir Dementyev published a new branch about Demo: pglite & electric-sql
  • Lucas Mendelowski announced a new repository hotwire-htmx-unpoly:Simple TODO application built with Rails to compare Hotwire, HTMX, and Unpoly
  • Rails Designer published a new gem stealth_dom_id - Extends Rails dom_id helper to support custom attribute-based identifiers
  • Evgeniy Demin published a new gem called database_schema_ownership - Provide an easy way to manage code ownership over a database schema

You will also find updates on their projects or libraries from a new Puma version 6.5.0, Bridgetown 2.0 Beta 3, Rodauth 2.37, a discussion on Ruby parser about how Rubocop will be affected by deprecating the current parser, the introduction of Fiber::Scheduler#blocking_operation_wait to Ruby and a lot more.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at newsletter.shortruby.com/p/edition-115

Comparison of image quality Twitter vs Bluesky

What kind of image (compressions, AR, ...)  do I need to upload to Bluesky to have them show high quality?

Here is a comparison (left: Twitter, right: Bluesky) of screenshots taken from MacOS / Safari, which I think has the best quality.

Comparison of images shared on Twitter vs Bluesky

RBS inline code sample from Anycable example

I was reading this article Hey, AnyCable speaking! Needing help with a Twilio-OpenAI connection? by Vladimir Dementyev over last weekend and noticed an example of RBS inline usage:

Code sample showing usage of RBS Inline

That made me curious about how the tool configuration is created to be used by the other pieces of sofware.

Thus I browsed the source code and found inside https://github.com/anycable/twilio-ai-demo/blob/demo/rbs-tools an exciting combination of parsing RBS Inline with Prism to read method definitions and generate functions for LLM:

Code sample from RBSTools module that parses method signatures

Source: module RBSTools::MethodDecl - I like what Vladimir did here and the idea to parse the method signature to create LLM functions. 

Written by Lucian Ghinda - Senior Ruby Developer by day, Curator of Short Ruby Newsletter during weekends