π Issue #12 - 26 Sep - 02 Oct 2022
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.
I feel the same π

π Thiago MassaΒ sharedΒ how to assign the previous result in Rails console:

π Greg NavisΒ sharedΒ code sample for using ActiveModel to validate forms without persistence

π Kirill ShevchenkoΒ sharedΒ code sample about using Ruby defined?:

and here is a reply from Josh Cheek:

π Matt SwansonΒ sharedΒ code sample about using compact_blank method:

Lucian Ghinda added to the conversation some ideas in case performance is important:

Β
π Peter SolnicaΒ sharedΒ a sample code showing how to use rightward assignment while verifying a service result:

π Steve PolitoΒ sharedΒ a migration example about create database index based on type cast value of a column:

π Thiago MassaΒ sharedΒ a configuration option to enable strict loading model that will raise error on N+1:

π Jason SwettΒ sharedΒ a nice opinion about what people call Rails magic is not exactly magic and we should think about it more like well documented rules:

π Greg NavisΒ sharedΒ about conditional class names in Rails ERB:

π Brad GesslerΒ sharedΒ a code sample about running ActiveJob on Fly.io:

π Brad GesslerΒ sharedΒ a code sample about making markdown-rails renderer work well, including code highlighting and Youtube tags

You should read the entire thread and see it working on his view-playground Rail app on Github. Also, if you want to use it in your rails app, Brad shared how.
π DorianΒ sharedΒ how to use ActionController::Parameters with_defaults,
which seems to be an alias for reverse_merge
:

π Joel DrapperΒ askedΒ about how Zeitwerk works when handling conflicting root directories:


You can read more about how nested root directories are loaded in Zeitwerk docs here.
He then added a suggestion about how to namespace files in a directory:

π Thiago MassaΒ sharedΒ how to run a small piece on code in your Rails app context (like you will run it in the Rails console):

π AkshayΒ sharedΒ a code sample about how to use Configurable concern:

π Kirill ShevchenkoΒ sharedΒ how to use Ruby built-in Tempfile class:

Please note that Mika Henriksson warned:
Can have weird βdisappearingβ side effects inside a docker container though.
Alpine Linux issue perhaps with the temp directory but it caused me a lot of headache. Problem went away after using regular files and cleaning them up after usage.
π Robbyrussell.RbΒ sharedΒ how to open a gem in an editor and look at the source code:

Here is a summary from all replies and with one thing that I added there about how to explore local installed gems source code:
π Prabin PoudelΒ sharedΒ a Rails anti-pattern thread talking about violation of MVC pattern by adding finders in views and controllers:

π Benoit BenoitΒ sharedΒ a new feature, just merged to Rails master (probably will be part of Rails 7.1) about conditionally setting log level:

π Thiago MassaΒ sharedΒ a code sample about strings and freeze and symbols:

It is also worth considering this reply from Josh Cheek, adding more context:

π Kirill ShevchenkoΒ sharedΒ how to enable YJIT when using Ruby 3.1:

π David CopelandΒ askedΒ a question about how to group db updates and enqueue job in a fault-tolerant way:

There are a couple of solutions proposed there:
Using interactor rollback
Using the newly published changeset gem (you can see an example of code behind this idea of changeset here)
Using Acidic Job principles and ideas - see an example here - but I recommend you to read this thread where David asks questions about the code shared by Stephen to understand more why that solution is written like that.
π Thiago MassaΒ shared a code sampleΒ about numbered params in Ruby:

Lucian added this context about how numbered params work:

It is also worth reading this exchange started with Joel reply about wanting an alias for _1.
If you are interested to read more about numbered params:
Read this ticket on Ruby where people discuss
it
And then this one about re-reconsidering
it
I think it is worth having an alias for _1, and it seems like `it` could be great for that.
π Greg NavisΒ sharedΒ a code sample showing how to use queue_as with a block to route jobs to different queues:

π Cezar HalmageanΒ sharedΒ a thread about how to migrate from import maps to esbuild:
π Fullstack RubyΒ shared about ::Data being merged to Ruby master:

Read the PR on Github for more details about this. Here is a short snapshot of the description provided on the PR by Victor Shepelev:
π Greg NavisΒ sharedΒ a code sample about filtering sensitive attributes in Active Record:

As John Duff noted, this will only filter sensitive information while inspecting. Add params filtering, not to write sensitive information in logs.
π Colleen SchnettlerΒ askedΒ what the most important Rails library/gem/package is:

Here are some of the responses:
annotate, awesome_print, better_errors, bullet, bundle-audit, byebug, capybara, chusaku, devise, draper, dry-monads, dry-validation, faker, faraday, flipper, guard, haml-rails, http.rb, js-routes, kaminari, lockbox, pagy, pay, prosopite, pry-rails, pry-usable, pundit, railseventstore, retest, rspec-rails, rubocop, shoulda, sidekiq, skunk, sorbet-runtime, strong_migrations
π Kirill ShevchenkoΒ sharedΒ a code sample about calling lambda and proc with square brackets in Ruby:

Josh Cheek added 7 ways to call a proc in Ruby (read more about it here):

π Nick SchwadererΒ askedΒ about problems with Rails:

Here are some of the answers:
If you read so far and you like the content, maybe you take into consideration sharing this and subscribe:
Related (but not Ruby specific)
π§ Richard SchneemanΒ sharedΒ a good thread about how to contribute to open source

π§ Brandon WeaverΒ sharedΒ an idea about a healthy mindset fore growing and learning:

π§ Yasuhiro Matsumoto shared a nice perspective about some of the debates regarding programming languages

π§ Heroku announced their new low-cost plans:

Read the official announcement here and see some reactions here on Reddit /r/ruby
There seems to be another announcement about a partnership with Github to offer Student Developer Program/
If you are an educator not from University you should give feedback on this Github issue and say what you need or how you see the support for this community.
π§ Dave PaolaΒ askedΒ what we do to familiarize ourselves with a new codebase:

Here are some of the answers to this question:
π§ Shopify EngineeringΒ askedΒ about what advice one would give to interns or CS students:

Here are some answers to this question, and I invite you to read the entire conversation as it has a lot more ideas:
π§ Jason SwettΒ sharedΒ hot take about frameworks:

He also added this in one of the replies:
Keeping large amounts of code understandable requires skill, and tools can't be a substitute for skill. (That's why frameworks can only help in the early stages, because they're tools.) - source @JasonSweet on Twitter
π§ Adrian MarinΒ sharedΒ a thread about a category of persona present on social media - the toxic developer.

It is also worth considering this response from Mika Henriksson:

Articles and Videos
Courses or Books or Communities
π Richard SchneemanΒ launchedΒ their new book How to Open Source. Buy the book at howtoopensource.dev
π₯ Noah GibbsΒ sharedΒ the video playlist of Ruby Learning Center. See it here
Something to read
Newsletters
π Emmanuel HayfordΒ shared a new edition of This Week in Rails.
π Marc Busqué sharedΒ their OSS update for September 2022.
π Joe Masilotti shared the September edition of The Hotwire dev newsletter
π Ruby LibHunt published their 332 edition of Awesome Ruby Newsletter
π Ruby Weekly published their 622 edition Sidekiq 7 (beta) and Sinatra 3 (for real)
π Ruby Radar published their 70 edition Hackathon Success
Articles
βπΎ Austin GilΒ sharedΒ a nice cool hidden feature of VS Code: Timeline view
βπΎ Robby Russell shared an older article with very good information about how to take over an existing Rails app
βπΎ Sam RubyΒ shared an article about how to run Ruby on Rails via region replicated sqlite 3 (what Fly calls LiteFS - distributed file system built for replication SQLite databases)
βπΎ Steve PolitoΒ sharedΒ an article about detecting anomalies in user behavior using PostgreSQL
Something to watch π₯ or listen π§
Videos
π₯ Drifting RubyΒ sharedΒ a new episode Downloading Cloud Database. See it on driftingruby.com
π₯ Eric BerryΒ sharedΒ an old (but still relevant) video about Arel by Cameron Dutro. See it Advanced aRel: When ActiveRecord Just Isn't Enough
π₯ Go RailsΒ sharedΒ a new video created by Collin Jilbert. See it β How to Deploy Rails to Render
π₯ Justin SearlsΒ shared a video they created to show a new way to sort Ruby objects. See β A better way to Sort Ruby Objects
π₯ Janko MarohniΔΒ shared a video they streamed about adding admin accounts to the Rodauth demo Rails app. See Adding admin accounts with Rodauth
π₯ Drifting RubyΒ sharedΒ the video log for This Week in Rails. See This Week in Rails Sept 30th, 2022
π₯ Aaron PattersonΒ sharedΒ a live stream with Vinicius Stock where they play around with Language Servers. See Pairin' with Aaron: Messing with Language Servers
π₯ Adrian Marin recommended we watch a video by RafaΕ Rothenberger from wroclove.rb conference. See Β Devise pitfalls and way to tighten security
π₯ Joel Drapper shared a pairing session with Stephen Margheim working on the Phlex compiler. See Phlex Ruby Compiler
Audio & Podcasts
π§ The Ruby on Rails PodcastΒ sharedΒ a new Ruby on Rails podcast episode. Listen β It's Not Only Sauerkraut and Pickles (Brittany + Nick)
π§ SchwadΒ sharedΒ a Twitter space recording named βCode with Jason LIVE!! Itβs not a goodbye foreverβ. Listen here
π§ Ruby For AllΒ sharedΒ a new episode they published where they talk about interviews with Brandon Weaver. Listen to Understanding Interviews with Brandon Weaver
π§ Remote RubyΒ shared a new episode about Rails Hackathon and Turbo 7.2 release. Listen to Rails Hackathon 2022 & Turbo 7.2 release
Gems, Libraries, and Updates
π§° Avo shared a new release of their powerful and flexible Rails admin. Check the release notes here or see a video of the new features here.
π§° LΓ‘zaro NixonΒ sharedΒ a Github repo of Trix extensions. See them here: github.com/lazaronixon. Examples of what you can find there: multiple headings and choosing between multiple colors.
π§° Mike PerhamΒ shared a Sidekiq 7.0 release. See the changelog. It comes with very nice things.
π§° Eric BerryΒ sharedΒ a new gem used for debugging whoop. Here are some examples:
Among the most exciting parts is the ability to add :explain for logging SQLs.
π§° Kasper Timm HansenΒ launchedΒ a new gem called active_job-performs that adds the performs macro to setup job by convention. Here is an example:
π§° Julian Rubisch shared their gem attractor for generating a report with code complexity metrics for Ruby and Javascript. This is a cool gem for knowing how your code base is.
Justin SearlsΒ shared a video that contained a new gem called put that helps with sorting arrays. Here is how the code looks like:
π§° Joel Drapper announced a change in Phlex from Phlex::Components to Phlex::Views:

πΈ Music to listen to while coding
This is just something extra this week, as I discovered on Reddit r/ruby two excellent playlists to listen to while coding:
Please consider sharing this on social media or with your colleagues: