Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
katafrakt’s garden 

This post is written in org

Recently I found myself doing more and more things using org-mode. Not surprisingly, I also wanted to use it to write articles here. With some time on my hands this weekend, I decided to give it a try and see how hard would it be to add org support to BridgetownWhich this blog uses as an SSG.

Even though Bridgetown supports adding own formats via converters, they have one big limitation:

Bridgetown will only convert files that have a YAML or Ruby Front Matter header at the top, even for converters you add using a plugin.

Of course, I could just add front-matter on top of my org file, but let's be honest: how silly it would look? I had to find a way to force Bridgetown to ignore its own rule…

Posts on Kevin Murphy 

RSpec Stubs The Object In Memory

Publish or Perish 🔗

Let’s say we’ve been sitting on a handful of blog posts that are ready to publish, but we haven’t released yet. This is a fictional story that in no way mirrors reality of any particular writer. Certainly not the author writing this post now. In a spirit of inspiration, we decide to write a small class to publish all these posts that exist in our system.

class DraftPost  def self.publish_all    Post.draft.map(&:publish)  endend

Rather than actually publish them, we’ve successfully procrastinated. We have a way to publish them, eventually. While we’re busy not actually publishing them, let’s test this method works.

Prolonged Publication Procrastination 🔗

We want to verify that…

Mintbit 

Customizing Rails Forms with a Custom FormBuilder

When building forms in Rails, we often need to add custom behavior or default styles to form fields. While Rails provides a flexible FormBuilder through form_for and form_with, there are times when you want to streamline repetitive tasks, such as adding CSS classes to every form input. This is where creating a custom FormBuilder comes in handy.

In this blog post, we’ll explore how to create a CustomFormBuilder that automatically applies a CSS class to form fields, ensuring consistent styling without redundant code. We’ll also see how to implement it using form_for.

Why Use a Custom FormBuilder?

A FormBuilder in Rails helps generate form elements like text fields, password fields, and…

Ruby on Rails 

Solid Cable as default, 2 new Guides PRs, and much more!

Hey everyone, Happy Friday the 13 🎃

Vipul here with the latest updates for This Week in Rails, from the very awesome EuRuKo this week! Let’s dive in.

New Guides Pull Request for review
Two new Guides Pull Requests are up for community review this week. If you are well versed in Action Mailer, or Error Reporting please review and submit your feedback here:

Add Solid Cable
This change starts to use Solid Cable as the default Action Cable adapter in production, configured as a separate queue database in config/database.yml. It keeps messages in a table and continuously polls for updates.

This makes it possible to drop the…

Remote Ruby 

Rocky Mountain Ruby 2024

In this episode, Jason, Chris, and Andrew are joined by the organizers of the Rocky
Mountain Ruby Conference, including Bekki Freeman, Spike Ilacqua, and Marty
Haught, discuss their experiences and the journey of building and sustaining the vibrant Ruby community in Colorado. They delve into the challenges and triumphs of organizing the Rocky Mountain Ruby conference, the importance of community meetups, and the inspiration behind their commitment to fostering connections among Ruby developers.

They also share their personal motivations, the intricacies involved in conference
planning, and the vital role of Ruby Central in supporting regional conferences. Hit
download now to hear more!

DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 16

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 16. Use Modules as Mixins

Modules are good for a lot more than just namespacing in Ruby. They're containers for behaviors, certainly, but what if we could also use that to share behavior across different classes? Well that's exactly what a mixin is in Ruby, and it's how we create…

Giant Robots Smashing Into Other Giant Robots 

How to train senior developers in Ruby on Rails

It’s not uncommon for a company to acquire another one, and bring the developers along. Occasionally, these developers don’t have experience with the acquiring company’s tech stack.

If you’re in a leadership position supporting this transition, it’s now your job to train these developers. You have a new team of developers with lots of business context and web development experience but have never used your tech stack before.

In this post, I will share resources and strategies for helping you get them onboarded in the Ruby on Rails ecosystem.

Where are the new developers coming from?

The developers already have lots of experience and bring different perspectives to the team,…

Island94.org 

The Novice Problem

Brandon Weaver’s “Beyond Senior - Metric Obsessions” has been stuck in my mind ever since we caught up at a SF Ruby Meetup and chatted about rules-adherence as a general problem:

…by definition a vast majority of your engineers are likely to be concentrated more towards the novice end of the spectrum, and will frequently over rate themselves on this scale.

If folks in the novice to advanced beginner stages are known for a rigid adherence to rules and almost legalistic approach to them what do you think might happen if you give them a giant list of metrics [, coding rules, linter warnings, dependency violations, or type-checking errors]?

Will they exercise discretion and nuance?…

This is coming from the Dreyfus Model of Skills Acquisition, which is like Shuhari but with more levels:

  1. Novice:
    • “rigid adherence to taught rules or plans”
    • no exercise of “discretionary judgment”
  2. Advanced beginner
    • limited “situational perception”
    • all aspects of work treated…
Julia Evans 

Reasons I still love the fish shell

I wrote about how much I love fish in this blog post from 2017 and, 7 years of using it every day later, I’ve found even more reasons to love it. So I thought I’d write a new post with both the old reasons I loved it and some reasons.

This came up today because I was trying to figure out why my terminal doesn’t break anymore when I cat a binary to my terminal, the answer was “fish fixes the terminal!“, and I just thought that was really nice.

1. no configuration

In 10 years of using fish I have never found a single thing I wanted to configure. It just works the way I want. My fish config file just has:

  • environment variables
  • aliases (alias ls eza, alias vim nvim, etc)
  • the occasional d…
Awesome Ruby Newsletter 

💎 Issue 434 - NextJS to Rails: The code that powers our new marketing site

Ruby Weekly 

An even faster future for JRuby

#​719 — September 12, 2024

Read on the Web

🇧🇦 It's been a quiet week in the Ruby world, probably as many folks are at the EuRuKo Ruby conference in Sarajevo, including Matz. If you're there, I hope you're having a great time!
__
Peter Cooper, your editor

Ruby Weekly

JRuby on CRaC: An Effort to Improve JRuby's Startup TimeCRaC is an OpenJDK project to speed up start times by using restorable checkpoints, and while JRuby is already a pretty fast implementation, its startup times could certainly be improved. Could CRaC be a big help? Yes!

Charles Oliver Nutter

The Rails Renaissance — Rails 8 has a lot of…

Hanami Mastery newest episodes! 

#53 Advanced forms in Hanami 2

Working with templates is a hard job and eliminating the logic out of them is absolutely not trivial. In this episode we'll use Hanami tools to implement advanced forms.
Rails Designer 

Create a Resizable Navigation with Stimulus

If your app has a sidebar navigation, which is quite common with most screens being wide enough to support these days, making it resizable might be a great feature to add. Giving this customization allows your users to tweak the screen for the task at hand. Maybe they want to focus on writing their next big piece or maybe they split their screen, making the default width a bit too wide.

Whatever the reason, resizing the sidebar navigation (or any other component) is easy with JavaScript and thus with Stimulus. Let’s dive right in. Let’s set up the basics in HTML:

<main data-controller="resizer" class="flex">
  <nav data-resizer-target="container" class="relative w-1/6">
    <!--…
DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 15

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 15. Use Modules as Name Spaces

Eventually you're going to need to organize your Ruby code. Sure, we have classes that represent objects, but how are they grouped? What do they belong to? Which team owns them? That's part of the reason why namespaces are such a popular concept, and in…

DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 14

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 14. (Don't) Use Class Instance Variables

From the last article:

Speaking of, next up we have class instance variables, which admittedly I am very much not a fan of for the same reasons I just mentioned, so we'll see how that article goes.

This article does have something similar…

AkitaOnRails.com 

X.com censurado no Brasil: escolha NOSTR

Pra quem não conhece, é como se fosse uma rede social descentralizada (mas não serve só pra isso). Isso é atraente: não tem como tirar do ar. É que nem "bitcoin" só que mensagens. É só um protocolo o "Notes and Other Stuff Transmitted by Relays", "Nostr".

Aliás, o protocolo foi criado um brasileiro (!!), @fiatjaf (que quer tentar manter sua identidade anônima), em 2020.

Aos interessados em Threads, Mastodon ou BlueSky, vou comentar sobre isso na 2a metade do artigo.

Sendo Nostr só um protocolo, não tem um único site ou um único app. Tem vários que implementam o protocolo (pense como protocolo de email, não existe só Gmail).

Dos poucos que testei, estou inclinado a ficar no Primal.net ou

Na…

Charles Oliver Nutter 

JRuby on CRaC Part 1: Let’s Get CRaCking!

Hello friends! Today we start a series on improving JRuby startup time using the new OpenJDK Project CRaC (Coordinated Restore at Checkpoint)! If that sounds intriguing, read on!

The Hardest Problem in JRuby

JRuby is the most successful and widely-deployed alternative Ruby implementation, but is frequently overlooked as an option due to several misconceptions:

“JRuby won’t work for my app because we use C extensions”

Most popular C extensions have JRuby equivalents (using pure-Ruby or our similar JRuby extension API), and others can be replaced by equivalent JVM libraries. Many applications will work out of the box with a simple bundle install.

“A Java-based Ruby can’t possibly be…

RoRvsWild's blog 

GenevaRB is back!

GenevaRB is more than just a meetup. It’s a free, friendly gathering, with insightful talks and refreshing drinks, where you can connect with the local Ruby developers. It’s the place to be if you’re in Geneva, Switzerland, and passionate about Ruby and Rails. We’re thrilled to support this fantastic initiative, and we’re grateful to Yannis for making it happen again.

The following four dates are already been announced:

  • September 18th: Optimizing Financial Data Ingestion at Inyova (Rafael Millán)
  • October 16th: Developer Tooling for the Modern Rails & Hotwire era (Marco Roth)
  • November 13th: Rails deployment with Kamal (Sean Carroll, GitLab)
  • December 11th: More everyday performance rules…

Join us and register on the meetup page. If you have an idea for an upcoming talk, we’d love to hear it! We even have a Swiss Tradition of offering some chocolate to the…

Mintbit 

The Magic of ActiveRecord Connections

ActiveRecord::Base.connection plays a crucial role in Rails applications by providing a direct interface to the database. It allows you to interact with the database connection associated with your ActiveRecord models. Here’s a detailed overview of its role and usage:

Role of ActiveRecord::Base.connection

  1. Database Connection Management: It manages the connection to the database for all ActiveRecord models. Rails automatically establishes a connection to the database defined in the configuration file, and ActiveRecord::Base.connection provides access to this connection.

  2. Executing Raw SQL: You can use ActiveRecord::Base.connection to execute raw SQL queries directly…

The Ruby on Rails Podcast 

Episode 523: Welcome Back, Nick Schwaderer

Our illustrious cohost Nick is back from parental leave! We talk about life as a parent and coder, committing to Ruby on Rails, being coworkers and finding time for hobbies. I'm looking forward to recording with Nick again.

Ruby Magic by AppSignal 

Ruby on Rails 7.1: Partial Strict Locals and Their Gotchas

Rails partials have been around for years, but they can be clunky since they're just ERB snippets without a backing object structure.

Recently, libraries like ViewComponent and Phlex have tried to improve the view layer by adding more semantic structure to the templates. These are great libraries and I personally reach for ViewComponent on almost every project I work on. That said, I still feel the humble Rails partial still works great for many use cases.

The Rails team is always trying to improve its offering, so let's look at a new feature introduced in Rails 7.1: strict locals!

Rails Partials and Local Variables

We can pass in arbitrary local variables into Rails partials and they're…

DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 13

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 13. Get the Behavior you Need with Singleton and Class Methods

Not everything fits inside a nice box. For every rule there's counterexample, for every model of thinking there's a weakness, and the same can be said about Object Oriented programming. Some have gone to much more colorful…

Posts on Kevin Murphy 

Frequently Played Sept 2024

Frequently Played 🔗

I tend to listen to the same songs or albums on repeat that are evocative of how I’m feeling or what’s going on with me. Here is what I’m currently listening to over, and over, and over, and over, again.

The Blues, Mary 🔗

Brian Fallon may be best known as the lead singer of The Gaslight Anthem. I appreciate his solo work during their hiatus too. I think future entries of this series will feature a lot of Brian’s output.

Full Lyrics

I learned how to cry
In them lonesome September nights
I learned to get by
With the dogs and the dirt and the charm of the street
I fell asleep most nights
With your pictures right behind my eyes, your eyes

And cause your smile
Is bright like the…

The Bike Shed 

439: Async Ruby & Rails with Trevor Turk

How can asynchronous programming transform your Ruby on Rails applications? Today, Stephanie sits down with Hello Weather co-creator Trevor Turk to unpack asynchronous programming in Ruby on Rails. Trevor Turk is a seasoned software developer known for his work on Hello Weather, a minimalist weather app that delivers essential weather data quickly and precisely. He’s also the creator of Weather Machine, an advanced weather data platform designed to serve reliable and highly accurate forecasts via API. With a background that includes work at innovative tech companies, Trevor brings years of experience in developing intuitive, user-friendly digital tools. Trevor talks about the focus…

GarrettDimon.com Posts 

The Neverending Story

Applets. ActiveX. Flash. Flex. Silverlight. Angular. React. Plenty of corporations thought they knew better but failed to see the larger picture. Innovation as collaboration is one thing, but innovation as an attempt at displacement of compromise and collaboration is another.

BigBinary Blog 

Introduction to custom Babel plugins

Babel is a tool that allows us to write modernJavaScript while ensuring it works across older browsers. Instead of generatingbinary code like traditional compilers, Babel performs source-to-sourcetransformations.

For example, with modern JavaScript, we might use arrow functions like this:

const add = (a, b) => a + b;

This code works in modern browsers but not in older ones, like InternetExplorer, which does not support arrow functions. Without Babel, we would needto use older syntax to ensure compatibility, which limits our use of modernfeatures. Babel solves this problem by transforming the modern code into anolder syntax that more browsers can handle. For example, Babel converts thearrow…

Evil Martians 

A letter to founders: join the local-first movement!

Authors: Alex Berdiugin, Account Director, Victoria Melnikova, Head of New Business, and Travis Turner, Tech EditorTopic: Business

Local-first is the next big thing, and in fact, it’s already disrupting the market of professional tools with one killer feature: zero latency. Read on to find out what that means, if it makes sense for your product and market, and how to ride this wave!

Local-first is the "next" big thing, and in fact, it’s already disrupting the market of professional tools with one killer feature: zero latency (also known as the zero latency illusion 🪄). Read on to find out what that means, if it makes sense for your product and market, and how to ride this wave!

Saeloun Blog 

Rails 7.1 Adds Support For Composite Key Multi-Column Ordering In ActiveRecord::Batches

ActiveRecord::Batches module provides methods like find_each, find_in_batches, and in_batches to process records in batches, reducing memory consumption.

By default, records are processed in ascending order by primary key(ID).

# default asc order

User.find_each do |user|
  puts user.id
end

User Load (0.4ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1  [["LIMIT", 1000]]

1
2
3

Before

Before Rails 7.1, ActiveRecord::Batches methods - like find_each, find_in_batches, and in_batches supported ORDER BY the primary key (ID) in either ascending or descending order.

class User < ApplicationRecord
  self.primary_key = [:first_name, :last_name]
end
# Before Rails 7.1,…
Hashrocket - Ruby Posts 

The Rails Renaissance

The power of Rails with Turbo and Stimulus.

With the imminent release of Rails 8 and the exciting new version of Hotwire's Turbo library, the buzz around Rails has been growing. Hotwire, which stands for 'HTML Over The Wire', encompasses the Turbo, Stimulus, and Strada libraries. Rails has integrated Turbo and Stimulus into the framework, providing a wealth of modern, high-speed functionality. Let's explore how these new additions, combined with some classic features, can make Rails the perfect choice for your next project, saving you time and boosting your productivity.

Turbo 8

Turbo has been around for a while now, but with Turbo 8, responsive page loading has never been more…

DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 12

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 12. Create Classes that Understand Equality

So equality. How does it even work in Ruby? What makes two things equal? Not equal? Maybe kinda sorta equal, those cases are real fun. Well this chapter is going to take a look at a lot of those

An Identifier for your Documents

T…

DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 11

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 11. Define Operators Respectfully

Ruby, like some other languages, allows you to overload operators and a lot of them at that. Remember that every operator in Ruby is a method, meaning 1 + 2 == 1.+(2), and that includes certain prefix operators as well.

The book mentions that it's…

Notes to self 

Avoiding environment conflicts with Kamal and Dotenv

We often use Dotenv in Rails for managing environment variables in development. But both Kamal and Dotenv works with .env files by default. Let’s see how to solve this conflict.

Environment conflicts

We often rely on an .env file in development when using Dotenv. This is a direct opposite for Kamal that also loads the same .env file, but for deployment. As an example we might rely on RAILS_MASTER_KEY in an .env file which will differ from development and production. To figure out the right action to take we have to understand what these tools do with the env files in the first place.

Dotenv environments

Dotenv loads several env files by default by their priority. This depends on the…

Short Ruby Newsletter 

Short Ruby News - Edition #106

The one about Rails performance benchmarks, new Array#fetch_values method and Rails launched an official video series with tips and best practices.
Matt Stuchlik 

Injecting syscall faults in Python and Ruby

Since syscalls are near the very bottom of any software stack, their misbehavior can be particularly hard to test for. Stuff like running out of disk space, network connections timing out or bumping into system limits all ultimately manifest as a syscall failing somewhere. If you want your code to be resilient to these kinds of failures, it sure would be nice if you could simulate these situations easily.

Now, you might already know strace lets you trace system calls, but did you know it can also change their behavior? You can modify their input and output, inject errors and add time delays (though be aware of the limitations).

To demonstrate how it could be useful, I’ve added the ability…

Gusto Engineering - Medium 

Tackling the Human Cost of R&D Tax Credit Qualification with AI-Powered Models

Co-authored by Edward Kung.

The Gusto R&D Tax Credits product helps clients identify and maximize the R&D tax credits that they qualify for. One component of this process is calculating the percentage of their general ledger (GL) accounts that would qualify for tax credits according to IRS rules, as well as categorizing them in a defined set of categories.

Currently, these percentages are calculated by a team of quantitative tax associates (quants) under the guidance of a CPA.

A sample GL looks like this:

+---------------------------------+---------------------------------------------------+-----------+
| Account Name | Expense Description | Amoun…
Mintbit 

Cache Key Versioning in Rails

cache_key_with_version is a method used in Ruby on Rails to generate a cache key for a model object that includes its version number. This method is helpful for ensuring cache consistency, as it combines the object’s unique ID, updated timestamp, and a version number to create a unique cache key.

How it Works

The cache_key_with_version method is typically available in Rails models that include ActiveRecord::Base. It generates a cache key by combining:

  1. Model Name: The name of the model.
  2. ID: The primary key of the record.
  3. Updated Timestamp: The timestamp of the last update to the record.
  4. Record Version (if available): The version number of the record, if your model has a lock_vers…

Example Usage

Suppose you have a Post model in your Rails application:

1
2
3
class Post < ApplicationReco…
Rails Designer 

Connected and Disconnected Target Callbacks with Stimulus

In a previous article I wrote about the change callbacks for the Values API. This time I want to highlight the Connect and Disconnect callbacks for targets.

A quick recap on targets: targets lets you reference important elements by name. They can be set up like so:

<div data-controller="eggs">
  <h2>Eggs</h2>

  <ul>
    <li data-eggs-target="item">🥚</li>
  </ul>
</div>

Then in your Stimulus controller:

// app/javascript/controllers/eggs_controller.js
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = ["item"];
  // …
}

Keep track of new targets being added

Let’s assume above eggs list only allows you to add more eggs,…

37signals Dev 

The gift of constraints

One of the hardest things about shipping products is balancing this contradiction: you want to do the best possible work everywhere, but optimizing every piece takes time, and time is finite.

I’ve done a poor job here countless times in my career. And I have seen many others struggle here, too. If you like your craft, it’s natural that you want to do your best all the time. But the best and good enough are different things: you must learn when and where to aim for each.

This is easy to understand, but it’s very hard to put into practice when it is time to do the work. How do you convince creative individuals who love building things to build less? How do you get someone who enjoys…

Giant Robots Smashing Into Other Giant Robots 

Comment your regular expressions

Regular expressions have a reputation for being cryptic and arcane, and with good reason: their syntax is dense and non-obvious. Unfortunately that leads many people to not view them as real code, so they copy-and-paste them without analyzing them to verify their behavior, or they ignore them in code reviews. This isn’t ideal; is there a way to help ensure that regexes are treated with the significance that they warrant?

Yes: we can comment them! For example, let’s take this regex for a USA postal code in Ruby:

usa_postal_code_pattern = /\A\d{5}(-\d{4})?\z/

That’s pretty hard to read; no wonder we want to gloss over it. Using Ruby’s “extended mode” for regexes via the x flag (and a %r{⋯}

Hotwire Weekly 

Week 36 - Lazy-load Turbo Frames early, Turbo Laravel Morphing Support, and more!

Hotwire Weekly Logo

Welcome to Hotwire Weekly!

Welcome to another issue of Hotwire Weekly! Next week, EuRuKo 2024 kicks off in Sarajevo, September 11-13, featuring several Hotwire and Hotwire-adjacent talks:

Enjoy…

DEV Community: Brandon Weaver 

Let's Read - Eloquent Ruby - Ch 10

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 10. Construct Your Classes from Short, Focused Methods

One of the greatest differences for me between a Ruby program and an eloquent one is the ability to name and encapsulate ideas effectively. A program isn't one giant blob of text, it's a series of concepts and ideas stitched…

Giant Robots Smashing Into Other Giant Robots 

This week in #dev (Aug 30, 2024)

Welcome to another edition of This Week in #dev, a series of posts where we bring some of our most interesting Slack conversations to the public.

Discovering Gemfile’s .tool-versions Feature for Ruby Versioning

Silumesii Maboshe discovered that the Gemfile can utilize a .tool-versions file to specify the Ruby version:

# in Gemfile
source "https://rubygems.org"

ruby file: ".tool-versions"

Testing Block Execution in RSpec

Neil Carvalho discusses a common spec pattern for testing blocks, which involves setting a flag to true when a method is executed. He provides an example:

executed = false

object_under_test.method_under_test do
  executed = true
end

expect(execut…

He mentions RSpec’s yield_control as a more elegant…

expect { |b| o…
Remote Ruby 

Andrew is Triggered by Jason Cs JSON B Columns

In today’s eventful episode of Remote Ruby, Jason, Chris, and Andrew dive into a range of tech topics, from the latest updates and issues with text editors, like Redactor, caching strategies, challenges of managing JSONB columns in databases, to debates on programming trends and outdated technology. They even share a few personal stories, including Jason’s prepper grandfather and his unique experiences as an officiant. There’s also some banter and jokes about sleep schedules, “Idiocracy,” and Bivy Bags. What’s a Bivy Bag? Hit download now to find out!


Ruby on Rails 

Solid Cache and Queue as default backends and more

Hi, Wojtek here. Let’s explore this week’s changes in the Rails codebase.

Add Solid Cache
Solid Cache will be the new default caching backend for production deployments out of the box in Rails 8.

Add Solid Queue
Configure Solid Queue as the default Active Job backend alongside Solid Cache. Both can be skipped with --skip-solid.

Allow registering test directories for code statistics
Make it easier for third party gems, to register test directories.

Silence healthcheck requests from the log
Add Rails::Rack::SilenceRequest middleware and use it via config.silence_healthcheck_path = path to silence requests to “/up”. This prevents the Kamal-required healthchecks from clogging up the…

Fix authentication generator double signature
Previously the session id stored in the cookies…

Awesome Ruby Newsletter 

💎 Issue 433 - Say No To Partials And Helpers For A Maintainable Rails Front-End

Ruby Central 

Ruby Central Welcomes Marty Haught as Interim Lead for RubyGems and Bundler

Ruby Central is excited to announce Marty Haught will be joining us on an interim basis to lead our open source work, including the RubyGems and Bundler projects, effective today. We are glad to welcome Marty back - he was previously the co-leader of Ruby Central and is an alumnus of the open source infrastructure company Hashicorp as well as rubygems.org infrastructure sponsor Fastly.

Marty has been part of the Ruby community since 2006, a leader of Ruby Central since 2012, and member of our Open Source committee since its creation last year. His knack for collaboration has helped teams do their best in a friendly and supportive space.  

We want to thank André Arko for his many years…

Ruby on Rails 

GitHub joins Rails World 2024 as Platinum Sponsor and Track 1 Host

We are excited to welcome GitHub as a Platinum Sponsor for Rails World 2024, taking place in Toronto on September 26th and 27th. As a Core member of the Rails Foundation and a key player in the global developer community - not to mention the Ruby community - GitHub’s participation and support means a lot to us.

Sixteen years since GitHub’s inception, and at the heart of every product and ship still lies our community – those coding from nearly every corner of the world. Our continued partnership and now sponsorship with Rails World is an extension of not just our commitment to developers, but our deep belief in what the developer community can accomplish for the betterment of mankind.

Rails World attendees can find GitHub at their booth in the Sponsor Garden - be sure to stop by for a chat with the team. GitHub…

Ruby Weekly 

Real-time Ruby profiling

#​718 — September 5, 2024

Read on the Web

Ruby Weekly

Ruby 3.3.5 Released — Not a big release (you’ll be waiting till Christmas Day for that!) but a scheduled minor bug fix release covering a variety of issues. Based on the current schedule, 3.3.6 should land in early November.

Takashi Kokubun

The Thread API: Concurrent, Colorless Ruby — The latest in JP’s ongoing series about concurrency, parallelism and asynchronous programming. This time, the topic is Thread’s API, an oft misunderstood part of Ruby.

JP Camara

🚨 Need to Upgrade Rails on a Budget? — Too many security holes in production?…

Ruby Rogues 

Cloud Migration, Server Costs, and CDN Challenges - RUBY 650

In this episode, Chuck, Ayush, and Valentino join Olly Headey as he shares his expansive career journey, from co-founding FreeAgent to navigating the intricate world of cloud migration and technology adoption. They dive deeply into the various challenges and decisions involved in choosing frameworks like React, tackling server costs with CDN solutions, and simplifying complex tech stacks. Olly also discusses his experiences with boot camps, emphasizing the importance of foundational knowledge over trendy frameworks.
They touch on the significance of dependencies in tech projects, the evolving landscape of Ruby usage beyond Rails, and the practicalities of AWS CloudFront integrations. Olly…
Rails Designer 

Building Nested Forms in Rails with Stimulus

In a previous article I wrote about nested forms with Turbo and no other dependencies. This is a great solution that works remarkably well, but I want to explore another option using Stimulus.

Why explore another option? While the Turbo solution works great, there might be cases the round-trip to the server might be a bit much for simple, static HTML. After all, there’s no extra data needed from the server to render the nested fields.

So let’s build the same feature, but now with Stimulus instead of Turbo.

Image description

So, again for this article, I assume you have a modern Rails app ready and the following basics in place:

  • Survey; rails generate model Survey name
  • Question; rails generate…
DEV Community: Brandon Weaver 

Let's Read – Eloquent Ruby – Ch 9

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 9. Write Specs!

Warning: This chapter has had a significant amount of changes since the original writing as the syntax for RSpec especially has evolved dramatically since then, so be sure to compare how things have evolved but be careful not to use some of the older syntax as it will…

Ah specs.…

Josh Software 

A Guide for Manual Vulnerability Testing

Let’s dive into the world of cybersecurity and explore how we can keep our digital assets safe from prying eyes and malicious attacks. Understanding Vulnerability Testing Vulnerability testing isn’t just about finding weaknesses in systems; it’s about safeguarding digital homes from unseen threats. Just like checking the locks and windows before bed, manual vulnerability testing … Continue reading A Guide for Manual Vulnerability Testing
DEV Community: Brandon Weaver 

Let's Read – Eloquent Ruby – Ch 8

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 8. Embrace Dynamic Typing

This chapter, in particular, is very amusing given the more recent zeitgeist around static typing in every language, Ruby included. It leads in with common questions folks ask like how in the world you can write reliable programs without types, and why you…

Everyday Rails 

Testing with RSpec book updates for September 2024

Now with an updated take on DRY tests and creating test data with factory_bot!
Charles Oliver Nutter 

JRuby: Upcoming Projects

Hello friends! I’m re-entering the blogspace with an update on JRuby status and some of the exciting projects we have coming up in the latter half of 2024. Let’s get started!

A New Path

As I posted on the JRuby blog in July, Red Hat’s sponsorship of JRuby has come to an end after twelve exciting years. It’s hard to feel anything but gratitude after so many years of unconditional support, but this transition has brought new challenges and opportunities to my work on JRuby and JVM languages.

In the two months since then, my wife and business partner Sondra and I have been ramping up our new business entity, Headius Enterprises, and have been signing up JRuby users for our basic “Pro”…

Saeloun Blog 

Rails 7.1 Adds *_deliver Callbacks To ActionMailer

ActionMailer allows us to send emails from our application using mailer classes and views.

Callbacks are methods that get called at specific points in the lifecycle of a mailer action. With the introduction of the *_deliver callbacks, we can now hook into the email delivery process more effectively.

Before

If we want to hook into the lifecycle of email delivery, we have to use interceptors and observers to modify, monitor, or perform actions on emails before or after they are sent.

class UserInvitationMailer < ApplicationMailer
  before_action :set_user

  def send_invitation_email
    mail(to: @user.email, subject: 'Welcome to Saeloun')
  end

  private

  def set_user
    @user = par…
UserInvitationMailer.with(user: @user).send_invitation_email.deliver_later

Interceptors are used to modify or prevent the delivery of emails…

Mintbit 

Ruby 3.0: Optimizing Applications with GC.compact

Ruby 3.0 introduced a new method to its garbage collector called GC.compact, which offers a powerful way to manage memory by reducing fragmentation in long-running applications. This feature can lead to significant improvements in memory usage and overall application performance, especially in scenarios where memory fragmentation becomes a bottleneck.

Understanding GC.compact

Garbage collection (GC) is a critical process in Ruby, responsible for freeing up memory by cleaning out objects that are no longer in use. However, over time, especially in applications that run continuously, memory fragmentation can occur. This happens when memory is allocated and deallocated in such a way that…

BigBinary Blog 

Upgrade Ruby using dual boot

Recently, we upgraded all neeto product's Ruby versionfrom 3.2.2 to 3.3.0 using "dual-booting".

Dual-booting is a process that allows you to run your application with differentsets of dependencies, making it easy to switch between them. This approachenables you to quickly test your code with both the current and the newerversion of what you are upgrading, ensuring that everything works smoothlybefore fully committing to the upgrade.

How to dual-boot Ruby?

The dual-boot technique involves maintaining two separate Gemfile.lock fileswithin your Rails project: one for the current version of Ruby and another forthe next version you're upgrading to.

To get started, first create a symbolic link for Ge…

Write Software, Well 

Routing Concerns in Rails

📕
This post was originally published in the Rails Router handbook.
Routing Concerns in Rails

Sometimes, you have common routes that you want to reuse inside other resources and routes. For example, imagine that your application has two resources, photos and posts.

# config/routes.rb

resources :posts
resources :photos

Next, you decide that you want to allow users to add comments under both posts and photos. That means you'll want to nest comments under both resources as follows:

# config/routes.rb

resources :posts do
  resources :comments
end

resources :photos do
  resources :comments
end

This is simple enough. But, you can imagine this can get repetitive if you have few more 'commentable' resources, i.e. resources that…

Radan Skorić's personal site 

How to load a lazy loaded turbo frame a bit before it scrolls into view

Turbo supports lazy loaded frames that start loading only when they enter into the view. It’s a wonderful feature that can save server resources for rarely seen content, only loading when the user is actually able to see it. However, since it only starts loading after it is visible, there’s always a small delay from it scrolling into view to it being loaded. It would be nice to start loading h...
The Bike Shed 

438: Writing abstractions in tests

Writing abstractions in tests can be surprisingly similar to storytelling. The most masterful stories are those where the author has stripped away all of the extra information, and given you just enough knowledge to be immersed and aware of what is going on. But striking that balance can be tricky, both in storytelling and abstractions in tests. Too much information and you risk overwhelming the reader. Too little and they won’t understand why things are operating the way they are. Today, Stephanie and Joël get into some of the more controversial practices around testing, why people use them, and how to strike the right balance with your information. They discuss the most common…

Ruby News 

Ruby 3.3.5 Released

Ruby 3.3.5 has been released.

This is a routine update that includes minor bug fixes. We recommend upgrading your Ruby version at your earliest convenience. For more details, please refer to the GitHub release notes.

Release Schedule

As previously announced, we intend to release the latest stable Ruby version (currently Ruby 3.3) every 2 months following a .1 release.

We expect to release Ruby 3.3.6 on November 5th and Ruby 3.3.7 on January 7th. If any significant changes arise that impact a large number of users, we may release a new version earlier than scheduled.

Download

DEV Community: Brandon Weaver 

Let's Read – Eloquent Ruby – Ch 7

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2024 — Ruby 3.3.x).

Chapter 7. Treat Everything Like an Object—Because Everything Is

Something that is easy to forget, given all the talk of every different paradigm Ruby supports, is that at its core it's a deeply Object Oriented language. This chapter explores a lot of those themes, along with the common tools…

The Code Gardener 

Is code even relevant anymore?

Is code even relevant anymore?

There is a misconception in the software development industry dating back decades that assumes the most valuable thing we programmers can do is type production code into an editor. That may have been true at some point. But, with the advent of high-level programming languages in the 1950s, our role began to change. By 1999, Martin Fowler put it this way:

“Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.”

– Martin Fowler, Refactoring: Improving the Design of Existing Code

In other words, we’d moved from translating requirements into machine code, to translating requirements into machine-readable, structured, human language. And as…

Short Ruby Newsletter 

Short Ruby News - Edition #105

Discover new Ruby launches, code samples, and gems. Highlights include Kamal 2 insights, Ruby coding tips, and AI tools for Rails.
Mintbit 

Custom Database Indexes in Rails

Implementing a custom database index in a Rails migration is a powerful way to optimize database queries and improve application performance. Indexes can significantly speed up data retrieval operations by allowing the database to find rows more efficiently.

Here’s a step-by-step guide on how to implement a custom database index in a Rails migration, along with some examples and best practices.

Step 1: Generate a Migration

First, generate a new migration file using the Rails generator. You can do this by running the following command:

1
rails generate migration AddCustomIndexToTableName

This will create a migration file in the db/migrate directory.

Step 2: Add the Index to the…

Rails Designer 

Refactor Stimulus.js Controllers to Use Change Callbacks

Stimulus’ values API has a great change callback function. This allows you to respond whenever a value changes. 🦉

For a quick refresher: the values API allows you read (and write!) data attributes to the controller’s element.

You define them like so in the HTML: <div data-controller="counter" data-counter-time-value="10">10</div>.

Then in the controller define them in the static values:

export default class extends Controller {
  static values = { time: Number }
}

With above controller you might expect a connect function to start the timer.

// app/javascripts/controllers/counter_controller.js
export default class extends Controller {
  static values = { time: Number }

  connect() {
Hotwire Weekly 

Week 35 - New Hotwire Course, Hotwire for the Terminal, and more!

Hotwire Weekly Logo

Welcome to Hotwire Weekly!

Welcome to the another issue of Hotwire Weekly! This edition covers the latest Hotwire articles and videos.

Happy reading! 🚀✨

📚 Articles, Tutorials, and Videos

The Hello Hotwire course is live! - Andy Leverenz announced the launch of his new Hello Hotwire course - a successor course to Hello Rails. Hello Hotwire is a free course with premium build-along modules for developers looking to dive into Hotwire using Ruby on Rails with a fresh perspective.

Nested Forms With Turbo (without dependencies) - Rails Designer explains how to create nested forms in Ruby on Rails using Turbo, eliminating the need for third-party dependencies. It provides a step-by-step guide to…

Drifting Ruby Screencasts 

Dependent Fields with Hotwire

Large forms can be overwhelming to fill out, especially if not all of the fields are required. In this episode, we'll look at creating a stimulus controller to conditionally display fields based on the input of another field.
Alchemists: Articles 

Ruby Modules

Cover
Ruby Modules

At a high level, Ruby modules provide the following key benefits:

  • Namespaces: Allows you to namespace, organize your objects, and/or nest objects.

  • Multiple Inheritance: Provides multiple inheritance to add behavior in the form of extra methods to existing objects either at the class and/or instance level.

  • Functions: Encapsulates purely functional methods which can be messaged directly like any other Ruby object.

This article will spend time exploring this feature set so let’s dive in!

Object Hierarchy

Cover

The above illustrates what you can see from the console:

Module.ancestors.reverse
# [
#   BasicObject,
#   Kernel,
#   Object…
wasabigeek's blog 

Using the XReal AIR 2 Pros for Remote Work (Programming)

I’d been pondering adding a pair of AR glasses to my remote work setup, as an alternative to a portable monitor. Having seen good reviews and physically trying the XREAL Airs in Japan, I picked up a pair when they went on sale - just in time for a two week trip, where I’d be working remotely. The verdict after two weeks? I’ll keep using them for my travel work setup, but I’m not giving up my 27-inch monitor at home.

XREAL Air 2 Pros plugged in without the nosepads.jpeg

The setup

I got the XREAL Air 2 Pros. The key difference from the base model is that this comes with chromatic lenses, allowing you to change the tint with the press of a button, and allowing the lenses to get dark enough that you can skip using the lens…

Ruby on Rails 

Shopify is the official Toronto City Host for Rails World 2024

Once we announced Toronto as this year’s Rails World 2024 location, Shopify had one wish: that everyone attending Rails World would experience the best of what their city has to offer, before, during, and to close out the event. With the event taking place in their backyard, it was only fitting that they become the official Toronto Rails World City Host.

What does it mean to be the official City Host? It means that Shopify is going above and beyond to make this an unforgettable Rails World for you.

Here’s how:

Pre-Registration, September 25th - If you are already in town on the 25th, grab your badge early, have a welcome drink courtesy of Shopify, and meet up with other Rails World…

Ruby Rogues 

Developing your development - RUBY 649

Mason McLead from software.com shows us the editor-integrated suite of tools that help you become a better developer. We find out what music makes you code better (and worse), how data reveals the habits of the world's top coders and why Saturday is code day.


Links

Picks


Become a supporter of this podcast: https://www.spreaker.com/podcast/ruby-rogues--6102073/support.
Once a Maintainer 

Once a Maintainer: Bryan Housel

Welcome to Once a Maintainer, where we interview open source maintainers and tell their story.

This week we’re talking to Bryan Housel, maintainer of several widely used packages in the Open Street Map ecosystem, including Rapid Editor and OSM Lab. Bryan is an avid runner, which led to his interest in mapping the world around him. He spoke to us from New Jersey.

Once a Maintainer is written by the team at Infield, a platform for managing open source dependency upgrades.

How did you get into software development?

I guess I’ve always been into problem solving. As a kid I played computer games like a lot of kids, and it seemed like going to study something that I already liked would be a good…

Remote Ruby 

Mike Dalessio on HTML parsing & sanitization and SQLite

In this episode, hosts Chris and Andrew sit down with Mike Dalessio, a seasoned Ruby developer and contributor to numerous open-source projects. Mike shares his journey from his early days with Ruby, including his contributions to Shopify and pivotal projects like Nokogiri and Mechanize. The conversation also delves into the challenges and innovations in HTML sanitization in Rails, the evolution of SQLite gems, and the significance of managerial experience in enhancing software development skills. The episode wraps up with insights into the continuous improvements and collaborative efforts in the Ruby community. Hit download to hear more!


Ruby on Rails 

Last call for Luminary nominations, SQLite3 full-text search and more!

Hi, it’s Greg. Let’s explore this week’s changes in the Rails codebase.

Last call for Rails Luminary nominations
If you know someone who has contributed to the Rails ecosystem and community with exceptional code, documentation, enthusiasm, or assistance, submit your nomination by September 2nd.

Fix Devcontainer generator with –dev option path error
This pull request has been created because the devcontainer generator with the --dev option failed (rails g devcontainer --dev)(the app generator worked just fine with the flag) due to a path issue.

Strip encrypted file contents
If you accidentally add a newline to the end of an encrypted file (like Rails credentials), the content file will…

Josh Software 

Beyond the Map: Ola’s Journey to Innovate with Homegrown Tech

In an era increasingly characterized by technological independence and innovation, Ola’s initiative to create and implement its own mapping solution, Ola Maps, marks a pivotal development. This strategic move, projected to save the company approximately ₹100 crores annually by moving away from Azure and Google Maps, underscores a significant trend in India’s technology sector: the … Continue reading Beyond the Map: Ola’s Journey to Innovate with Homegrown Tech
Awesome Ruby Newsletter 

💎 Issue 432 - Ruby's official documentation just got a new look

AkitaOnRails.com 

X.com censurado no Brasil? Como configurar Mullvad VPN

No Brasil, qualquer coisa pode ser censurada a qualquer momento. E hoje, 29 de agosto de 2024, mais uma vez querem dar um jeito de eliminar o X por aqui.

A primeira parte é um tutorial sobre Mullvad VPN mas a segunda parte é um resumão do que aconteceu até agora (30/8).

Mas a Internet existe pra que nós não tenhamos que nos dobrar frente a autoridades idiotas. Pra isso existem VPNs, por exemplo.

Eu fiz um fio no X mostrando sobre uma das opções mais interessantes, o Mullvad VPN e neste post vou só compilar o que já tinha postado no X, mas pra deixar num formato mais fácil de achar depois.

Esse Mulvad VPN parece ser uma das melhores opções. Nesse post vou mostrar o que gostei. Primeiro de…

Ruby Weekly 

RubyKaigi direct to your living room

#​717 — August 29, 2024

Read on the Web

Ruby Weekly

▶  The RubyKaigi 2024 Talks — RubyKaigi, essentially Ruby’s ‘home’ conference in Japan, took place in May, and now you can enjoy it from wherever you are. With a mix of Japanese and English language talks, there are some great talks worth your time, including Vinicius Stock on the state of Ruby dev tooling, Maxime Chevalier-Boisvert on breaking the Ruby performance barrier, Koichi Sasada on Ractors, Takashi Kokubun explaining how YJIT makes Rails faster, and Emma Haruka Iwao showing off Ruby’s role in a world record Pi-calculation attempt.

YouTube

💡 If…

Rails Designer 

Launch a Turbo Modal with URL Params Using Stimulus

Having certain screens in a modal (or slide over) on top of your app can be great to give that context the user needs for the action they want to take. Think: settings for a page they are editing, a notifications list or a list of tasks to be done.

This is really easy to create with Rails and Turbo (and even easier with Rails Designer’s ModalComponent or SlideOverComponent) 💡). But what if you want to link to that screen from an email or allow your users to share it with their team, like: example.com?v=settings. No problem with a small, single-purpose Stimulus controller!

Yes, the beauty of Turbo Frames is you can link to a standalone page for, say, the settings of a page, but that would…

Evil Martians 

How to quickly (and weightlessly) convert Chrome extensions to Safari

Authors: Nina Torgunakova, Frontend Engineer, and Travis Turner, Tech EditorTopics: Case Study, Frontend, Plugin and Extension Creation, JavaScript, TypeScript, Swift, React

Created a browser extension for Chrome and now want it available in Safari too? Learn how and get guidelines on the extra steps needed for App Store publication.

Created a useful browser extension for Chrome and now you want it to be available in Safari as well? In this post, we’ll share how to quickly (and with minimal effort) convert your Chrome extension into a Safari one, plus we’ll cover any extra implementations necessary to be ready for App Store publication!

Code With Rails 

How to save a recently viewed list of pages with Stimulus and localStorage

Creating a "recently viewed pages" list can significantly enhance the user experience by providing easy navigation and a history of recently accessed content. Seeing how we are already using Rails, we are going to leverage Stimulus. Also, instead of storing the information on the server, we will use localStorage to persist the viewed pages data across sessions.

Why Use Stimulus and localStorage?

Usually for UI interactions, I prefer keeping things as lightweight as possible. This is why I prefer AlpineJS over Stimulus.

In this case, however, Stimulus is a good choice because there's a bit more logic in the JavaScript.

We will also use localStorage as a client-side storage mechanism. Its ideal…

GarrettDimon.com Posts 

Structure Your ERb and Partials for more Maintainable Front-end Code in Rails

It’s not always clear how to make the most of partials and helpers in Rails and know when to put what code where. Regardless of the methods, we all still want to organize the elements that help bridge the front-end and back-end with readable and maintainable code.

The Ruby on Rails Podcast 

Episode 522: Mentoring Junior Devs with Adam Cuppy

A recent focus of many in the community has been expanding the community. We all love Rails and want to create the best community possible. Part of this focus has to include early career devs. We need to expose them to Rails and mentor them into the senior developers and tech leaders we need in the future. Adam Cuppy joins the show today to teach how to be better mentors.

Show Notes
Mentorship In Three Acts: https://www.youtube.com/watch?v=eDX5WH1uLz8
Chapter One: https://www.chapterone.org/
Adam on LinkedIn: https://www.linkedin.com/in/adamcuppy/

RubySec 

CVE-2024-45409 (ruby-saml): SAML authentication bypass via Incorrect XPath selector

Ruby-SAML in <= 12.2 and 1.13.0 <= 1.16.0 does not properly verify the signature of the SAML Response. An unauthenticated attacker with access to any signed saml document (by the IdP) can thus forge a SAML Response/Assertion with arbitrary contents. This would allow the attacker to log in as arbitrary user within the vulnerable system.
Planet Argon Blog 

New Kid on the Block: A Digital Marketing Internship Experience

New Kid on the Block: A Digital Marketing Internship Experience

Sydni Johnson reflects on her rewarding journey as a Digital Marketing Intern at Planet Argon, where she overcame initial anxieties, embraced new skills, and learned the value of collaboration and persistence in a supportive environment.

Continue Reading

BigBinary Blog 

Simplifying code with standardized pagination, sorting, and search

Neeto is a collection of products. Here, we standardizeboilerplate and repetitive code intoNanos. The search, sorting,and pagination functionalities are essential for every listing page. We realizedthat each product had its own custom implementations for these operations,resulting in a lot of duplicated code. We wanted this logic to be abstracted andhandled uniformly.

Sorting and pagination

If you have worked with tables, you may already be familiar with the followingcode. In this example, we are using theTable componentfrom NeetoUI. It is the developer'sresponsibility to handle the sorting and pagination logic, make the API callswith an updated payload, and ensure that the URL is updated…

imp…
Ruby on Rails 

AppSignal returns as a Platinum Sponsor at this year’s Rails World

In the lead up to Rails World, there are a few sponsors that we would like to highlight who are going above and beyond to make this an unforgettable Rails World for you.

First up: AppSignal.

AppSignal is once again stepping up as a Platinum sponsor for Rails World 2024, taking place in Toronto on September 26th and 27th. This marks their second time as a Platinum sponsor at Rails World, and we couldn’t be more excited to have them back, or more grateful for their support.

A quick aside: AppSignal has long been one of the biggest supporters of events and meetups in the Ruby space. In 2024 alone, they will sponsor an impressive 22 Ruby events across the globe, including shipping a…

dmitrytsepelev.dev 

How to test graphql-ruby responses

Most of software engineers write tests. Some people use Ruby. Some of them use GraphQL. While testing queries and mutations has little differences compared to controller specs (at the end of the day—they both use HTTP requests), subscriptions are a bit more tricky. In this short post I’ll show you how I test my GraphQL backends.

I will use RSpec, but you can easily port these approaches to any other testing framework you prefer.

Queries and types

There are two approaches of testing data fetch: you can check either requests or types. In case of requests, you can have a single spec file that fetches a lot of data. If you decide to go with types—you should have a separate spec per type.

I…

Performance Action Pack - a cost effective way to audit and optimize your Rails app 

Easy to Overlook PostgreSQL Performance Issues in Rails Apps

Performance issues in the PostgreSQL layer usually start to manifest only when your app reaches a certain scale. In this blog post, I’ll discuss easy-to-miss database config tweaks and common problems that I’ve encountered in multiple Rails projects.

Tuning random_page_cost in PostgreSQL

random_page_cost is infamously misconfigured in the default PostgreSQL settings. This value represents how expensive it is to fetch a row using a database index. A related seq_page_cost represents the cost to fetch a row using an in-memory sequential scan. The default value of 4 for random_page_cost compared to 1 for seq_page_cost indicates that it’s significantly more expensive to fetch data using…

Mintbit 

Understanding the Difference Between f.select and select_tag in Rails Forms

When working with forms in Ruby on Rails, you might encounter two similar methods for generating dropdown fields: f.select and select_tag. Although they both create select elements, there are important differences between them that can affect how you structure your forms and handle data. Let’s explore these differences and discuss when to use each method.

This question arose for me while I was working on similar forms with a colleague. During a code review, my colleague suggested that I use f.select instead of select_tag, which led me to dive deeper into understanding the differences and benefits of each approach.

f.select

The f.select method is a helper that belongs to form_for or form_…. It…

The Bike Shed 

437: Contributing to Open Source in the Midst of Daily Work with Steve Polito

Are you passionate about open source but struggling to find time amidst your daily work? Today on the podcast, Joël Quenneville sits down with Steve Polito to discuss practical strategies for making meaningful contributions to the open-source community, even when your schedule is packed. Steve is a developer with extensive experience in the open-source world seamlessly. He’s known for his ability to integrate open-source contributions into his daily workflow, all while maintaining high productivity in his professional role. In our conversation, we explore balancing professional responsibilities with open-source contributions. Steve walks us through his process, from the importance…

Short Ruby Newsletter 

Short Ruby News - Edition #104

The one with Josef's new book about Minitest, where Xavier celebrates 15 years of maintaining Rails contributors app and where Andrew launches state-of-the-art transformers gem for Ruby
naildrivin5.com - David Bryant Copeland's Website 

Create public-facing unique keys alongside your primary keys

Peter Shilling wrote a blog post about generating what he calls “cool ids” for models in Rails. Instead of numbers, models have an id prefixed with its type, like cus_abcdefg1234 for a customer. I like the idea, but don’t think these ids should be used as primary keys. External IDs are incredibly useful for a lot of things, but they aren’t great as primary keys. I’ll explain what public-facing external IDs are, how to make them, and why they shouldn’t be your primary keys.

Screenshot of Stripe's Admin UI showing the ID for a payment intent Screenshot of Stripe's Admin UI showing the ID for a payment intent

Stripe’s admin UI surfaces identifiers for various entities, but these identifiers aren’t numbers, nor are the UUIDs. They are values like cus_73…

RubyGems Blog 

3.5.18 Released

RubyGems 3.5.18 includes enhancements and bug fixes.

To update to the latest RubyGems you can run:

gem update --system

To install RubyGems by hand see the Download RubyGems page.

## Enhancements:

  • Installs bundler 2.5.18 as a default gem.

## Bug fixes:

  • Fix gem uninstall <name>:<version> failing on shadowed default gems. Pull request #7949 by deivid-rodriguez

SHA256 Checksums:

  • rubygems-3.5.18.tgz
    a99163d03286850559134448e4c666fa32513407b63f1c277e5142b75180db56
  • rubygems-3.5.18.zip
    9b4fcf33c92aaf8bdc1c3c3711d22cadb12327cac388ae56e87a3795d9f5920a
  • rubygems-update-3.5.18.gem
    60460dae859b7714b9f64f846f6e99b8e876845b006476d82d4d0d13ef53fda4
Rails Designer 

Tidy up your Rails code with `inquiry`

This short article is less product-engineering/UI focused, but does help you as a developer write tidier code. For Rails Designer v1 I refactored some code in the components. One the of the improvements I made was using inquiry more.

I mentioned this ActiveSupport extension in this this article about lesser known Rails helpers too, but I thought it worthy of its own article.

So previously a component might looked like this:

class DropdownComponent
  def initialize(theme: "light")
    @theme = theme
  end

  erb_template <<~ERB
    <%= tag.div "content", class: class_names("block, {"bg-white": light_theme?, "bg-black": dark_theme?}) %>
  ERB

  private

   def light_theme? = @theme == "li…

I personally like a (internal) API like this; it helps with reading the code instead of doing mental gymnastics needed to parse the variable (@theme) and its value ("light" or "dark"

So I was pretty…

Josh Software 

Guide to JSON Marshal/Unmarshal and Encode/Decode

Introduction JSON is a lightweight data-interchange format that is easy for humans to read and write, and easy for machines to parse and generate. In Go, working with JSON is made simple with the encoding/json package. This blog will explore the fundamentals of JSON marshal/unmarshal and encode/decode in Go, when to use them, a comparison of their … Continue reading Guide to JSON Marshal/Unmarshal and Encode/Decode
Hotwire Weekly 

Week 34 - Hotwire with Django, Stimulus Social Share Button, and more!

Hotwire Weekly Logo

Welcome to Hotwire Weekly!

Welcome to the another issue of Hotwire Weekly! This edition covers the latest Hotwire articles and videos.

Happy reading! 🚀✨

📚 Articles, Tutorials, and Videos

Combining Hotwire with Django to Ship your SaaS Faster - This article by Michael Yin (the maintainer of the Turbo helpers for Django) explores integrating Hotwire with Django. He's looking to add real-time, dynamic features to Django apps without heavy JavaScript. It provides practical examples and insights on how to implement this modern frontend approach within a Django environment.

Designing Accordion Settings Panels with Tailwind CSS, Stimulus and Rails - Brian Casel's video demonstrates how to design…

Ruby on Rails 

ActionText store_if_blank, SQLite non-GVL-blocking busy handler, and more!

Hi, it’s zzak. Let’s explore this week’s changes in the Rails codebase.

In case you missed it, Rails 7.2.1 and 7.1.4 were released this week!

Allow use of alternative database interfaces
Prior to this PR, rails dbconsole was hardcoded to use the default interface for the given database. This command can now be configured via the config.active_record.database_cli option.

Encryption casting with “encrypts” before “serialize”
This PR ensures encrypted binary data is properly handled in PostgreSQL.

Add “store_if_blank” option to “has_rich_text”
A new option was added to ActionText to allow configuring whether or not to store empty rich text fields. This PR introduces a store_if_blank option…

Closer to Code 

Under the Hood: Enhancing Karafka’s CPU and Memory Efficiency

Introduction

Now and then, I like to go on a performance improvement hunt because life isn't just about adding new features. Recently, I have been focusing on enhancing efficiency, particularly regarding CPU and memory usage in Karafka. Three of my recent pull requests (PR 117, PR 118, PR 123), have made some minor improvements, and this article is about them. These changes help reduce memory allocation and improve time tracking management in Karafka and WaterDrop.

Most of the time, such improvements are not significant, but when applied in crucial places, they can make things a bit faster.

When doing OSS, I think of myself as a middleman. Karafka runs in tens of thousands of processes, and…

Write Software, Well 

How to Count the Number of Commits After a Specific Commit in Git

💭
Taking a break from the usual Ruby / Rails posts to share a neat Git trick I learned recently.
How to Count the Number of Commits After a Specific Commit in Git

I often like to squash multiple commits together into a single commit. For this, I tend to use the git reset --soft HEAD~n command frequently, where n is the number of commits I'd like to cherrypick.

💡
Update: Ben pointed out in the comments that if you know which commit you want to reset to, you can simply do: git reset --soft <commit-id> instead of HEAD~n. Not sure why I never thought of this 🤦‍♂️. That said, the rest of the post is still valid to count the number of commits after a commit.

For a small number of commits, it's easy to just count the number of commits manually. However, often I have…

RubySec 

CVE-2024-43791 (request_store): request_store has Incorrect Default Permissions

### Impact The files published as part of request_store 1.3.2 have 0666 permissions, meaning that they are world-writable, which allows local users to execute arbitrary code. This version was published in 2017, and most production environments do not allow access for local users, so the chances of this being exploited are very low, given that the vast majority of users will have upgraded, and those that have not, if any, are not likely to be exposed. ### Patches I am not aware of any other version of the gem with incorrect permissions, so simply upgrading should fix the issue. ### Workarounds You could chmod the files yourself, I guess.
RubySec 

CVE-2024-43398 (rexml): REXML denial of service vulnerability

### Impact The REXML gem before 3.3.6 has a DoS vulnerability when it parses an XML that has many deep elements that have same local name attributes. If you need to parse untrusted XMLs with tree parser API like `REXML::Document.new`, you may be impacted to this vulnerability. If you use other parser APIs such as stream parser API and SAX2 parser API, this vulnerability is not affected. This vulnerability has been assigned the CVE identifier CVE-2024-43398. We strongly recommend upgrading the REXML gem. ### Patches The REXML gem 3.3.6 or later include the patch to fix the vulnerability. ### Workarounds Don't parse untrusted XMLs with tree parser API. ## Affected versions REXML gem…
GarrettDimon.com Posts 

Per Seat Pricing Sucks

We’re close to rolling out updated pricing for Flipper Cloud, and it goes against most of the advice we heard from other SaaS teams. We’re moving forward anyways because it feels like the right thing to do for our context.

> When we started billing for Flipper Cloud, we did what everyone else in the space was doing – per seat pricing. $20 per seat each month felt like plenty. As time has passed this choice has increasingly bothered me. The past few months I’ve been thinking about what type of billing I like.

Instead of strategizing about maximizing revenue, we focused on finding an approach that would maximize customer satisfaction while leaving room for reasonable profit. We could be…

GarrettDimon.com Posts 

Organizing Rails Code with ActiveRecord Associated Objects

The ActiveRecord::AssociatedObject gem is a great tool to help organize logic that fits nicely into an encapsulated concept but only ever needs to interact with one type of object.

Remote Ruby 

Rails 7.2 – First Impressions

In this episode, Jason, Chris, and Andrew dive deep into Ruby on Rails 7.2 discussions
and share their experiences with the new RC1 rate limited feature. The conversation
also covers the challenges of upgrading dependencies, the shift from asdf to mise for
faster language management and explores ways to simplify development workflows
with dev containers. There’s also a big debate on various testing methodologies,
comparing RSpec and minitest, and deliberate the merits and pitfalls of fixtures versus
factory libraries in maintaining robust codebases. Also, find out about Oaken, a hybrid
tool blending features of Fixtures, FactoryBot, and Fabricator. Hit download now!

Honeybadger
Honeybadger is an…
Ruby on Rails 

Rails 7.1.4 has been released!

Hi everyone,

I am happy to announce that Rails 7.1.4 has been released.

CHANGES since 7.1.3

To see a summary of changes, please read the release on GitHub:

7.1.4 CHANGELOG To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as…

Awesome Ruby Newsletter 

💎 Issue 431 - Proposal to change private method to work on Constants in Ruby

Ruby on Rails 

Rails 7.2.1 has been released!

Hi everyone,

I am happy to announce that Rails 7.2.1 has been released.

CHANGES since 7.2.0

To see a summary of changes, please read the release on GitHub:

7.2.1 CHANGELOG

To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as…