Short Ruby - edition #15
Briefly about everything happening in Ruby world
If you want a short excerpt of this newsletter containing only some of the images with code, I created one here. But I invite you to read the entire newsletter as it has excellent content 😊.
This edition was created with support from @adrianthedev from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and from @jcsrb, who sent me recommendations to include in the newsletter.
👉 Lucian Ghinda shared a thread about the growing Ruby community:
👉 Brandon Weaver shared a poll about the behavior of Hash.new():
Joel added an excellent rule that could be applied when doing code review:
Josh Cheek showed a funny way to use the Hash.new with arguments (source code Github)
Rein Henrichs replied with some more examples of using Hash.new:
Here is the official documentation about
Brandon submitted a feature request to Ruby with some proposal to change or warn when calling Hash.new with non-value objects.
You should read the entire discussion on Twitter as it has more explanations.
👉 Thiago Massa shared a code sample about using include to add methods to objects:
👉 Greg Navis shared a Rails tip about Active Record error messages to enable full message customization, defining attribute error format and providing an arbitrary error message:
👉 Brandon Weaver asked about how to find dead code in Ruby:
Here are some of the answers:
leftovers gem - suggested by Shane Becker
Deletion Driven Development - a video presentation at RubyKaigi 2016 by Chris Arcand
zombie_scout gem - suggested by Tom Reznick
a module named DeadCode - suggested by Weston Triemstra
coverband gem - suggested by Andy Waite
unused gem - suggested by David Bernheisel
Find AST tool - suggested by Jônatas Davi Paganini
👉 Emmanuel Hayford shared a tip for Rails 7 to define a to_s on the module and use it with link_to:
👉 Greg Navis shared code sample about complex validations in Ruby:
👉 Thiago Massa shared a code sample about using include and extend and the difference between them:
Jean Boussier shared is a concise explanation about the difference between extend and include:
He also shared a code sample explaining include and prepand:
👉 Maciej Mensfeld shared a warning about using
👉 Jason Swett shared an explanation about the difference between after_commit and after_save/after_destroy:
See the official documentation here.
👉 David shared a short bit of knowledge about ActiveRecord toggle method:
👉 Kirill Shevchenko shared a code sample showing how to remove a method from a class:
Chris Seaton shared a concise way to explain
👉 EK shared a quick tip about lazy loading images in Rails and specifying multiple sources:
👉 Steve Polito shared a code sample about updating all columns all at once:
👉 Marc Busqué shared a code sample about functional idiomatic ruby and currying:
Marc also submitted a feature request to Ruby.
👉 Zilvinas Kucinskas shared a code sample about return in lambda vs procs:
👉 Matt Swanson shared a code sample with two Rails methods
👉 Greg Navis shared a code sample about validation contexts in Rails:
👉 Janko Marohnić shared a code sample showing how to work with window function with Sequel:
👉 Greg Navis shared the strict option for Rails validates, which will raise an exception when validation fails:
👉 Tom Stuart shared a code sample showing that in Ruby 3.2 a hash pattern can be used to extract regular expressions named captures:
👉 Lucian Ghinda shared a code sample showing how to use forward argument notation:
👉 Bridgetown shared the registration is open for BridgetownConf:
👉 Kevin Newton shared a code sample showing that any expression can be part of the left-hand side of defining a method on an object:
👉 Kirill Shevchenko shared a code sample showing how to turn a Class into an Enumerator:
If you have read so far and you like the content, maybe you take into consideration sharing this and subscribing:
Related (but not Ruby-specific)
Mayank shared a simple trick to make attribute selectors case-insensitive:
Xavier Noria reminded us that when using the library, we should only use the public API and no private methods:
Vitaly Friedman shared an article written by UX team leader from WIX about how to write a good error message:
👉 Robby Russell shared a tip about using take command with a git repo:
Andrew Mason asked about favorite VSCode extensions:
Here are some of the answers:
Cursor Align (recommended by @adrianthedev)
Multiple cursor case preserve (recommended by @adrianthedev)
Toggler (recommended by @adrianthedev)
Peacock (recommended by @adrianthedev)
Edit csv (recommended by @sebwilgosz)
VSCode Neovim (recommended by @solnic29a)
indent-rainbow (recommended by @lucianghinda)
endwise (recommended by @danieldpence)
Git Web Links for VS Code (recommended by ideasasylum)
rails-latest-migration (recommended by @_swanson)
Sourcegraph (recommended by @jdorfman)
CodeSnap (recommended by @learnactrepeat)
Rails Run Specs (recommended by @learnactrepeat)
TODO Highlight (recommended by @learnactrepeat)
GitLens — Git supercharged (recommened by @alvincrespo)
🧐 Adrian Marin shared a tip about Tailwind 3.2 and usage of new variants for data-* attribute:
🧐 Dr Nic asked a question about the security risks of including magic links in emails:
Make the magic link valid for only 20 minutes
Use an Ajax post of click to log in that submits a form to mitigate the risk of link checkers logging in users.
Be aware of where you include this link, as people might forward an email without knowing there is a magic link
🧐 Nate Hopkins presented a kind of architectural challenge about running multiple SQLite instances:
You should read the entire conversation. Here are some of the recommended links there:
Ask HN: Has anybody shipped a web app at scale with 1 DB per account?
🧐 Jason Swett shared a new metaphor to think about technical debt:
🧐 Alex Russell shared a tread about Frontend development:
Maybe you might consider also reading the HN discussion for this tweet and the thread that Jared White shared quoting Alex Russell.
Articles and Videos
Noel Rappin shared they are working on a new edition of Programming Ruby - the Pickaxe book. Soon available on The Pragmatic Bookshelf
Timnan launched a new course Ruby Fundamentals: Learn Ruby and Build Fun Applications
Ben Orenstein shared they will start a new The 30-Day Code Quality Challenge in January.
Something to read
🗞 Emmanuel Hayford shared a new edition of This Weekin Rails: An Active Record improvement, performance gains and a bugfix!
🗞 Ruby Radar shared a new edition of 💎Ruby Radar #73 - Build a Bridge, Build a Town
🗞 Ruby Weekly shared a new edition 625 - Puma 6.0 release
🗞 Ruby LibHunt published a new edition of the Awesome Ruby Newsletter
Adrian Marin shared an article about open source Open-Core Companies Are Not Incentivized To Make Their Projects Good. But you should also read the thread where he shared how he thinks about open-source and how he positions Avo
William Kennedy shared an article they wrote for @honeybadgerapp about How to Build Your Own Rails Generator.
Yaroslav Shmarov shared an article they published about sending messages to Slack using Slack API. Send text, markdown, and files to Slack
Joel Drapper shared a new article they wrote about Magic template methods. You should also read the code in Github where Joel added some explanations.
Adrian Marin shared an article by Kieran Barker about using VSCode Branch Protection
Hanami Mastery shared a new article Pagination in Hanami apps with ROM
Vladimir Dementyev shared the second part of the series about View Component: ViewComponent in the Wild II: supercharging your components
Martin Spickermann shared an article written by Andy Croll about compressing HTML responses from within Rails: Compress Your HTML Responses
Adrian Marin shared an article written by Paweł Strzałkowski about How to rescue a transaction to roll back changes?
Maciej Mensfeld shared a new article about the security incident with rest_client written by Maria Korlotian: To use rest_client, or to use rest-client, that is the question
Jacques Chester shared an article about Finding Relationships Between Ruby’s Top 100 Packages and Their Dependencies
Adrian Valenzuela shared an article about building web apps: 12 Factor App Revisited
Tim Riley shared a new article they wrote about: Open source status update, September 2022
Ruby Lib Hunt shared an article about Top 10 highest paid programming languages in 2022 that includes Ruby in the 7th position.
Dr Nic shared an article they wrote about Friendly IDs for Ruby on Rails
Konnor Rogers shared a new article they wrote about All the ways to render an ActionText Attachment
The Ruby Dev shared an article written by Trevor Vardeman about Seed Dump: Rails - A Hidden Gem: Seed Dump
Something to watch 🎥 or listen 🎧
🎥 Drifting Ruby shared new episode about authentication using Magic Links
🎥 Yaroslav Shmarov published a new video about sending messages to Slack: Ruby on Rails #93 Slack API.
🎥 Richard Schneeman shared a new episode of How to Open Source with Richard Schneeman
🎥 The Rubber Duck Dev Show launched a new series Coding with Chris - Goblin Grinder part 0 (Tech Test and Project Planning)
🎥 Tom Stuart shared a new video part of the Making WebAsembly interpreter in Ruby part 9
🎥 Drifting Ruby shared the video version of This Week in Rails Oct 21st, 2022
🎧 Audio & Podcasts
🎧 The Ruby on Rails Podcast shared a new episode: Episode 440: World Traveler and Ruby 3.2 Preview (Brittany + Jemma)
🎧 Ruby For All shared a new episode: Episode 13: Julie's Epic Crossover
🎧 Joël Quenneville shared a new episode where DoodlingDev discusses the role of Ruby class methods: The Bike Shed: 358: Class Methods
🎧 Remote Ruby shared a new episode abvout Rails SaaS and a Shaved Stache
🧰 Gems, Libraries, and Updates
🧰 R7kamura shared a new gem rubocop-migration implementing rules that check migrations. See the source code on Github
🧰 Dry Rb shared the list of dry gems that are using Zeitwerk. Read the article dry-rb adopts Zeitwerk for code loading
🧰 Bozhidar Batsov shared a new release of Rubocop 1.37. Read the changelog to see the new cops added:
🧰 Alessandro Rodi shared a new gem passkit:
Your out-of-the-box solution to start serving Wallet Passes in your Ruby On Rails application.
🧰 Marco Roth shared they released v0.51.0 · stimulus-use/stimulus-use
🧰 Jeremy Evans shared they released a new version of Rodauth 2.26.0
🧰 Rubygems News shared a new version of tailwindcss-rails is released
🧰 Koichi Ito shared a new release of Rubocop Rails v. 2.17.0
🧰 Yasuo Honda shared that the Pull Request to support exclusion constraints was merged to Rails, and it will be released with Rails 7.1
🧰 Andrey Novikov shared they created a new gem that created a yabeda plugin for Sidekiq: yabeda-sidekiq
If you enjoyed this and want to receive the newsletter weekly in your inbox, consider subscribing: