Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Ruby Magic by AppSignal 

Get Started with Hotwire in Your Ruby on Rails App

Hotwire is a hot topic at the moment for every Rails developer. If you work with Rails, there is a good chance you have already heard a lot about it.

Hotwire is a completely new way of adding interactivity to your app with very few lines of code, and it works blazing fast by transmitting HTML over the wire. That means you can keep your hands clean from most Single Page Applications (SPA) frameworks. You can also keep your rendering logic centralized on the server, while still maintaining quick page load times and interactivity.

In this post, we'll look at the main components of Hotwire and how to use it in your Rails app. But first: what is Hotwire and why should you use it?

What Is Hotwire?

The Ruby on Rails Podcast 

Episode 425: The Railsconf At Home 2022 Ruby Podcast Panel

Moderated By:

Panelists:

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in monitoring into a single, easy to use platform. Go to Honeybadger.io and discover how Starr, Josh, and Ben created a 100% bootstrapped monitoring solution.

Scout APM

T…

Martian Chronicles, Evil Martians’ team blog 

The joy of Variable Fonts: getting started on the Frontend

Authors: Evgenii Shkodin, Frontend Engineer, Roman Shamin, Evil Martians Art Director, and Rita Klubochkina, Sr. Frontend Engineer

In this article, we’ll take a deep look at getting set up with variable fonts on the frontend, look at properly loading them, deal with settings, look at some ‘gotchas’ and more—read and learn!

In our last article describing why you should use variable fonts and examining some real-life use cases, we learned to love variable fonts (check it out!). This time around, we’re ready for that love to blossom into a beautiful new joy. This post is for web developers who are ready to take the variable font plunge, although designers (and the curious in general) are…

Saeloun Blog 

On how to better understand context and communicate questions

One of the biggest things I have learned in the past three years of running my own company is the importance of having transparency in communication with your employees.

On some days I feel I have lost many a few times in maintaining good communication with my team members, but I try to solve their problem statements as much as I can.

Context

The biggest thing I am learning is people, assume a lot of things without asking the right question.

This is probably how I was five years ago - rash and quick to make assumptions about people and situations.

The truth is that time is the best teacher. With time, I have learned well how to think through situations instead of jumping to…

Code with Jason 

154 - Chris Seaton, Researcher at Shopify

In this episode, Chris Seaton and I discuss just-in-time compiling for Ruby, Chris's path to becoming a researcher, speed concerns with Ruby, Truffle Ruby, the book Chris is currently writing and the value of having a non-technical side project. 

Shopify Engineering - Shopify Engineering 

The Story Behind Shopify’s Isospin Tooling

Island94.org 

Worknotes: Week 9

Two months! In my last update I wrote about an overwhelming sense of normalcy. That has continued, in a good way.

I am making good pace at completing my Engineering Manager bingo card. So far I have:

  • Worked with team and directors to write out quarterly OKRs, and close out the previous quarters
  • Gone through (well, shadowed) the half-yearly performance review process
  • Worked with a report through their departure from the team
  • Participated in the candidate interview loop, though not yet as a hiring manager

Something I’m inspired by

Writing OKRs with my team, boss, grandboss, and peer managers has been really, really, nice.

  • My team has been open within the OKR writing process,…
Saeloun Blog 

On how to better understand context and communicate questions

One of the biggest things I am learing three years in running my own company is how important it is have a good communication with your employees.

I feel somewhat lost many times, but I try to answer the best I can.

Context

The biggest thing I am learning is people, assume a lot of things without asking the right question.

I was this, 5 years ago. Rash and fast to make assumptions about people.

About situations.

I now think twice before saying something or assuming something about a situation.

Now imaging trying to provide this context to a team of 60+ people.

We are a super transparent company. I invite all and any feedback or criticism from my team.

But this cannot be fruitful…

Graceful.Dev 

Graceful.Dev Birthday Sale 2022

Hiya folks!

Avdi here, head gardener at Graceful.Dev. It’s my 42nd birthday today, and longtime followers know what that means: the biggest sale of the year! And this year, it’s bigger than ever before.

First, the TL;DR version: use code HAPPY0X2A to wish me happy birthday and get 42% off ANY individually purchasable course[s] OR a monthly or annual Pro membership. And since this is a very special birthday, I’ve decided to do something I don’t do very often: make the discount permanent for subscriptions. That’s right: if you use this discount for a Pro membership, your discounted rate will be locked-in for as long as your subscription stays active.

With the short version out…

Josh Software 

Introduction to Cypress

‘Cypress can test anything that runs in a browser’ Cypress supports faster End-to End(E2E) testing. Cypress gives devs access to all of the browser environments in which the site/app runs. What is End to End Testing? End to end testing is one of the testings in which the entire flow of the application is tested. … Continue reading Introduction to Cypress
BootrAils 

Ruby Enumerable Module

Introduction to the enumerable module

Modules are the major result of inheritance, since they allow us to execute actions without having to write code and sharing features among unrelated classes.

Because of Ruby being an object-oriented programming language, the role of data collections is very important. Some of the methods included in the enumerable module are so popular that people tend to think they are components of the Ruby language.

The methods included in these module can be grouped depending on the nature of its functionality:

  • Querying
  • Fetching
  • Searching and filtering
  • Iterating
  • Other

In this article, we will review each group of the module and analyze the main methods in it. But…

Ruby on Rails 

Improved PostgreSQL support, performance improvements and more…

Hi, this is Petrik, bringing you the latest news from the Rails world.

Optimize Active Record batching

Instead of specifying a long list of ids for batch queries (WHERE IN (…ids…)), Active Record will iterate in ranges (WHERE id >= num1 AND id < num2).

Add validity for PostgreSQL indexes

When creating indexes with CONCURRENTLY, you could to end up with an invalid index. You can now ask an index if it’s valid.

Add support for PostgreSQL exclusion constraints
This extends Active Record’s migration/schema dumping to support PostgreSQL exclusion constraints.

Add :force support to ActiveSupport::Cache::Store#fetch_multi
Setting force: true forces a cache “miss,” meaning we treat the cached…

Drifting Ruby Screencasts 

File Uploads and Cloud Storage

AWS S3 has been a reliable service over the years and for a long time it was the only option. However, in the past few years, there has been more cloud storage options that have popped up with compatible S3 APIs. These services can sometimes offer better pricing and speeds.
Remote Ruby 

Ruby Infrastructure with Ufuk Kayserilioglu

[00:08:50] Ufuk tells us how he got into programming and Ruby, and how he applied to a job that was put out by Rafael França. 


[00:12:21] We learn about how large the team was when Ufuk became manager, the growth of the, and if he had to learn a lot of management stuff.


[00:14:48] Ufuk gives is an overview of what his Ruby Infrastructure team encompasses.


[00:20:07] Does Shopify have any production services running TruffleRuby?


[00:22:21] If TuffleRuby becomes the Ruby implementation at Shopify, Jason wonders if Ufuk is still able to use the tooling he’s built for developer experience and apply it to TruffleRuby?


[00:25:12] Earlier Ufuk talked about organizing things as project teams…

Ruby in Better Programming on Medium 

Boost Performance With Asynchronous Queries in Rails 7

A look at the cool new feature in the latest framework version

Rails have a solid following due to its relative ease of use, superb documentation, and ardent community support.

Due to this following, improvements to some of Rails' more well-known drawbacks are constantly being sought. One common criticism leveled at Rails over the years is slow/poor performance. As a means to address this issue, the release of Rails 7 introduced a new method to allow for asynchronous querying.

New Kid On The Block

ActiveRecord queries execute in a synchronous manner. Take the following:

https://medium.com/media/59aebdcb53e92f4ba5ab98a7d9e37e15/href

The three queries will be made sequentially. The first queries…

Awesome Ruby Newsletter 

💎 Issue 319 - Ruby is the 7th most in demand language according to this programmer and scrapper.

Emmanuel Hayford 

4 Books For Intermediate Ruby And Rails Developers.

I’m a fan of good books. Through my Ruby and Rails journey, I’ve discovered a few excellent books that I’d like to share with fellow Rubyists. The authors of these books are experts in their fields. These books are my recommendation and I think they deserve some space on your desk.

By the way, having “intermediate” in the title means nothing, anyone can benefit in some form from these books. I try to pick a single audience to write for hence the title. In the coming days, I’ll create a booklist targeting entry-level and more experienced Ruby and Rails developers. Feel free to follow me on Twitter to stay in the loop.

In no particular order, here are four books I think are worth your time…

Shopify Engineering - Shopify Engineering 

How to Build Trust as a New Manager in a Fully Remote Team

Ruby Weekly 

Making Ruby's GC faster

🇺🇦 #​610 — June 30, 2022

Read on the Web

Ruby Weekly

(Not actually tenderlove, alas.) 

Tenderlove Cooks Up a Nifty Garbage Collector Optimization — Esteemed core team member Aaron Patterson has come up with a way to speed up Ruby’s garbage collector through the way it marks up instruction sequence objects. This is a very technical PR, but the TLDR is it could make GC ~60% faster in a Rails app (don’t get too excited, as this translates to a more modest perf improvement overall – but it’s still very cool!) It should end up in a Ruby version near you soon.

Aaron 'tenderlove' Patterson

Vite-lizing Rails: Get…

Ruby Rogues 

Development on the Road - RUBY 552

How do you develop remotely in new ecosystems such as when you are on vacation, in a coffee shop, or traveling for business?  The panel today discusses various strategies on how to manage these environments to achieve the most efficient outcomes.

In this episode…


  1. Visual Studio Code and remote SSH extensions
  2. VPN tunnel networks
  3. Distractions, comfort 
  4. Internet issues
  5. Time zone challenges
  6. Squid proxies 
  7. Personalized keyboards and monitors
  8. Smart suitcases 

Sponsors


Links


Picks

Saeloun Blog 

Ecma International approves ECMAScript 2022

On 22 June 2022, the 123rd Ecma General Assembly approved the ECMAScript 2022 language specification, .

It means that ECMAScript 2022 features are officially a standard now!

The list of all the features in ECMAScript 2022 is as below -

  1. Class Fields ( Private instance methods and accessors, Class Public Instance Fields & Private Instance Fields, Static class fields and private static methods)

  2. Ergonomic brand checks for Private Fields

  3. Class Static Block

  4. Top-level await

  5. RegExp Match Indices

  6. Object.hasOwn()

  7. Addition of .at() method in Array, String, TypedArray

  8. Error Cause

My talk from React Bangalore,…

BootrAils 

Ruby-on-Rails and Tailwind CSS Tutorial

Why should you use Tailwind CSS with Rails?

Tailwind CSS's core concept is its utility-first fundamentals, aka being able to build complex components from a constrained set of simple utilities. This brings many benefits and I'll be listing them in no particular order!

  1. No more wasting energy coming up with class names: Now to style a particular component, all you need to do is use the utility classes on said component directly in the HTML file. There's no longer any need to find the perfect abstract class name to name the component so you can style it in a separate CSS file.

  2. Rarely have to write new CSS: Since utilities are reusable and can cover nearly every conceivable situation, your…

RubySec 

CVE-2022-30122 (rack): Denial of Service Vulnerability in Rack Multipart Parsing

There is a possible denial of service vulnerability in the multipart parsing component of Rack. This vulnerability has been assigned the CVE identifier CVE-2022-30122. Versions Affected: >= 1.2 Not affected: < 1.2 Fixed Versions: 2.0.9.1, 2.1.4.1, 2.2.3.1 ## Impact Carefully crafted multipart POST requests can cause Rack's multipart parser to take much longer than expected, leading to a possible denial of service vulnerability. Impacted code will use Rack's multipart parser to parse multipart posts. This includes directly using the multipart parser like this: ``` params = Rack::Multipart.parse_multipart(env) ``` But it also includes reading POST data from a Rack request…
RubySec 

CVE-2022-30123 (rack): Possible shell escape sequence injection vulnerability in Rack

There is a possible shell escape sequence injection vulnerability in the Lint and CommonLogger components of Rack. This vulnerability has been assigned the CVE identifier CVE-2022-30123. Versions Affected: All. Not affected: None Fixed Versions: 2.0.9.1, 2.1.4.1, 2.2.3.1 ## Impact Carefully crafted requests can cause shell escape sequences to be written to the terminal via Rack's Lint middleware and CommonLogger middleware. These escape sequences can be leveraged to possibly execute commands in the victim's terminal. Impacted applications will have either of these middleware installed, and vulnerable apps may have something like this: ``` use Rack::Lint ``` Or ``` use…
Graceful.Dev 

Site News #13: Courses in Full Bloom

Hi there graceful devs,

Boy I’ve been waiting (and working) a long time to be able to announce today’s news: every single topic in the Graceful.Dev catalog—all ten years of material—is now organized into “Garden Path” courses. No more slogging through entire Tapastry (unless you want to!); no more searching for topics on testing or refactoring or growing your developer career. Now you can find the Garden Path on the theme you’re interested in and follow it. Each Garden Path has a new introduction, and each is further broken down into cohesive modules.

Not content to organize all the content into garden paths, I’ve also collected the paths into Garden Tours. If you’re not sure…

Honeybadger Developer Blog 

Memory Management in Python

Memory management is the process of efficiently managing computer memory (RAM). It involves allocating a piece of memory at run-time to the program when the program requests it and freeing the allocated memory for re-use when the program no longer needs it.

In languages like C or Rust, memory management is the responsibility of the programmer. The programmer has to manually allocate memory before it can be used by the program and release it when the program no longer needs it. In Python, memory management is automatic! Python automatically handles the allocation and deallocation of memory.

In this article, we will discuss the internals of memory management in Python. We'll also cover how…

Saeloun Blog 

Overuse of Rails engines

All of us would have used the well-known Devise gem for authentication in Rails but we can also say it’s an engine. So, simply put a Rails engine is the miniature edition of a Rails application. It comes with its own app folder which includes controllers, models, etc The only difference is, that an engine won’t work on its own so, to make it work we need to inject it into the main Rails application.

Rails engines were introduced to deal with bloated architectures by creating modular and reusable components but, everything is a curse if it is overused.

Rails engines can be a powerful asset if implemented using a well-thought design otherwise it could lead to various problems.

Leaki…

Shopify Engineering - Shopify Engineering 

Navigating Recurring Payments in India: A Backend Perspective

To address the new RBI framework for recurring payments in Shopify’s billing platform, we worked with a local payment provider that could accommodate both card-based payments as well as a local payment method called Unified Payments Interface (UPI).

More

OmbuLabs Blog 

Statement on Roe vs. Wade

At OmbuLabs, we value and respect our teammates and we are committed to protecting their mental health, physical health, and well-being.

On Friday June 24th, the Supreme Court announced a decision to overturn Roe v. Wade, removing the federal right to an abortion and leaving the decision up to each state.

We at OmbuLabs are prepared to ensure that all of our teammates have consistent and safe access to the benefits we provide, regardless of the state in which they live.

In response to the Supreme Court’s ruling, we are announcing that if one of our teammates lives in a state which restricts access to abortion, OmbuLabs will provide up to $5,000 in travel expense reimbursement to travel…

RubyGems Blog 

3.3.17 Released

RubyGems 3.3.17 includes enhancements and documentation.

To update to the latest RubyGems you can run:

gem update --system

To install RubyGems by hand see the Download RubyGems page.

## Enhancements:

  • Document gem env argument aliases and add gem env user_gemhome and gem env user_gemdir. Pull request #5644 by deivid-rodriguez
  • Improve error message when operating_system.rb fails to load. Pull request #5658 by deivid-rodriguez
  • Clean up temporary directory after generate_index --update. Pull request #5653 by graywolf-at-work
  • Simplify extension builder. Pull request #5626 by deivid-rodriguez
  • Installs bundler 2.3.17 as a default gem.

## Documentation:

  • Modify RubyGems issue…
The Ruby on Rails Podcast 

Episode 424: Women On Rails and VirtualCoffee.io with Aurelie Verrot

Enchanté. Aurelie Verrot is a developer originally from France who now lives in California. She is Software Engineer at Zendesk, working in the i18n team. She answers all of Brittany's questions about working at Zendesk, translating the beloved Women On Rails newsletter and VirtualCoffee.io.

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in monitoring into a single, easy to use platform. Go to Honeybadger.io and discover how Starr, Josh, and Ben created a 100%…

Jemma Issroff 

Setting and Getting Instance Variables

Thanks for watching my Brighton Ruby talk!

Here are links I referenced:

Test Double Blog 

Write cleaner, self-documented tests by defining methods in RSpec

When we write clean Ruby code, we try to pull out methods with descriptive names that do small amounts of work. It’s possible to do the same in RSpec, just as we would in a less “fluent” test framework like Ruby’s standard testing library Minitest.

RSpec’s describe and context methods define anonymous classes that behave like any other Ruby class as far as scope. Nested blocks even inherit methods from their containers and can use super. Each it block is more like a method, creating an instance of its outer describe/ context and executing in that scope.

With this, we can extract pieces of logic, share them between multiple specs, give them descriptive names, and call them from within it

Boring Rails: Skip the bullshit and ship fast |  

The most underrated Rails helper: dom_id

This post is part of Hotwire Summer: a new season of content on Boring Rails!

The dom_id helper in Rails is over a decade old, but has proven to be an invaluable concept in Hotwire.

This secret workhorse powers all kinds of HTML-related behavior in Rails. It has one key job: making it easy to associate application data with DOM elements.

dom_id takes two arguments: a record and an optional prefix.

The record can be anything that responds to to_key and model_name, but 99% of the time you are passing it an ActiveRecord model. The prefix can be anything that responds to to_s, but 99% of the time it is a symbol.

From the docs:

dom_id(Post.find(45))       # => "post_45"
dom_id(Post.new)
Julia Evans 

Notes on running containers with bubblewrap

Hello! About a year ago I got mad about Docker container startup time. This was because I was building an nginx playground where I was starting a new “container” on every HTTP request, and so for it to feel reasonably snappy, nginx needed to start quickly.

Also, I was running this project on a pretty small cloud machine (256MB RAM), a small CPU, so I really wanted to avoid unnecessary overhead.

I’ve been looking for a way to run containers faster since then, but I couldn’t find one until last week when I discovered bubblewrap!! It’s very fast and I think it’s super cool, but I also ran into a bunch of fun problems that I wanted to write down for my future self.

some disclaimers

  • I’m…
Martian Chronicles, Evil Martians’ team blog 

Vite-lizing Rails: get live reload and hot replacement with Vite Ruby

Author: Vladimir Dementyev, Principal Backend Engineer at Evil Martians

Recently, I upgraded my AnyCable demo application to Ruby 3 and Rails 7 with its new asset management tooling. As a result, assets:precompile became fast as lightning, but we lost one important productivity feature along the way: live reloading. Switching back to Webpacker in 2022 was not a good idea. Luckily, Vite Ruby had been on my radar for quite some time, so I decided to give it a try.

Rails has had an answer to the assets problem since the Assets Pipeline (Sprockets) was introduced. That was an important step forward for the entire world of web development frameworks, not only for Ruby and Rails.

Then, the…

Code with Jason 

153 - Collin Donnell

In this episode, I welcome Collin Donnell back to discuss how to learn new techniques and technologies, Smalltalk, service objects and models, RailsConf, and speaking at conferences.

Saeloun Blog 

Rails adds --js alias to --javascript

Rails has these generators that we can use to customize every new app that we create based on our requirements.

Suppose, we want to create a new Rails app with Postgresql DB instead of the default sqlite3, then we can use the --database alias.

  rails new myapp --database=postgresql
  rails new myapp -d=postgresql

Similarly, we could also use these generator options to remove something we don’t want. For example, if we want to write our tests using RSpec and do not want the unnecessary test directory from getting created. We could use the -T or --skip-test aliases.

  rails new myapp -T
  rails new myapp --skip-test

In Rails 6, the option webpacker got replaced with --javascript to…

The Bike Shed 

344: Spinner Armageddon

Steph has an update and a question wrapped into one about the work that is being done to migrate the Test::Unit test over to RSpec.

Chris got to do something exciting this week using dry-monads. Success or failure?


This episode is brought to you by BuildPulse. Start your 14-day free trial of BuildPulse today.



Become a Sponsor of The Bike Shed!

Transcript:

AD: Flaky tests take the joy out of programming. You push up some code, wait for the tests to run, and the build fails because of a test that has nothing to do with your change. So you click rebuild, and you…

Test Double Blog 

Double Agent Profile: James Walker

Name: James Walker
Designation: Agent 0091
Double Agent Role: Senior Software Consultant
Special Skills: Mentoring and leadership
Aliases: jamesjosephwalker
Location: St. John’s, Newfoundland
Favorite Emoji: 😬

What impact are you proudest of in your career?

The brightest moments in my career are when I’ve been able to help someone learn something new or see themselves and the people around them in a new light. It’s one of the highest compliments to build enough trust with someone that they reach out for mentorship, and through collaboration find meaning and success beyond their expectations. A colleague once told me that my greatest strength is that I bring out the best in…

Hanami Mastery newest episodes! 

#23 Rubocop - 4 ways to reduce your frustration!

Rubocop recently managed to be listed as one of the most loved and most frustrating ruby gems which is quite an achievement. In this episode, I'll show you how to keep it only in the loved section.
JRuby.org News 

JRuby 9.2.21.0 Released

The JRuby community is pleased to announce the release of JRuby 9.2.21.0

JRuby 9.2.x is compatible with Ruby 2.5.x and stays in sync with C Ruby. As always there is a mix of miscellaneous fixes so be sure to read the issue list below. All users are encouraged to upgrade.

Thanks to our contributors this cycle for helping to maintain and improve JRuby 9.2: @dee-see, @edipofederle, @DirkMahler

Ruby Compatibility

  • Fixes for a memory leak in the frozen string cache have been backported. (#7021)

Java Integration

  • The internal cache for nested jar file contents has been optimized and a new option added for…
JRuby.org News 

JRuby 9.3.6.0 Released

The JRuby community is pleased to announce the release of JRuby 9.3.6.0

JRuby 9.3.x is compatible with Ruby 2.6.x and stays in sync with C Ruby. As always there is a mix of miscellaneous fixes so be sure to read the issue list below.

Thanks to our contributors this cycle for helping to improve stability and compatibility of JRuby 9.3: @ahorek, @keimar, @k77ch7

Ruby Compatibility

  • Fixed a leak in the frozen string cache and now ensure frozen strings are reused correctly without reencoding. (#7166, #7229, #7242)

Java Integration

  • The internal cache for nested jar file contents has been optimized and a…
Shopify Engineering - Shopify Engineering 

Perspectives on Onboarding: Joining Shopify as an Engineering Leader

What’s it really like for new engineering leaders at Shopify? I asked Avanti Ketkar and Maria Robledo, who both joined the team this past year, to spill the tea about their first few months. They share their perspectives on how the onboarding experience helped them build context, relationships, and trust.

More

Blogs on Hello Friend 

Recently in Ruby Core - June edition

Many Ruby developers don’t have time to keep up to date with the recent developments inside Ruby core. To make this easier I decided to write up the most recent progress that is happening inside the [Ruby Bug tracker](https://bugs.ruby-lang.org). I won’t summarize bug tickets, but only feature proposals. But if an important Bug ticket rises I will mention it at the end.
BootrAils 

Ruby inheritance

What is object oriented programming (OOP)?

Object Oriented Programming aims to bring the logics of the real world to programming languages in order to simplify and structure code. The easiest and most common way to understand OOP is by taking car manufacturers as example. All manufacturers build cars based on a shared map or blueprint that includes wheels, doors, engines, etc. In other words, every car is build on the same components but has custom attributes and features that also enable each car to do different things.

The basis to OOP are classes, which are the map to every object. Classes define the aspects and characteristics of an object, as well as its behavior. Let's see an example…

Honeybadger Developer Blog 

Full-text Search with Elasticsearch in Rails

Elasticsearch is one of the most popular search engines out there. Among the many big companies that love it and actively use it in their production, there are such giants as Netflix, Medium, GitHub.

Elasticsearch is very powerful, with the main use cases featuring full-text search, real-time log, and security analysis.

Unfortunately, Elasticsearch doesn't get much attention from the Rails community, so this article attempts to change this with two goals in mind: introduce the reader to the Elasticsearch concepts and show how to use it with Ruby on Rails.

You can find the source code of an example project that we're going to build here. The commit history more or less corresponds to the…

Notes to self 

Migrating Rails cookies to the new JSON serializer

How to move from Marshal to the new Rails 7 default JSON serializer.

I was recently upgrading Phrase to Rails 7. Big upgrades like that are usually being done with the most minimal changes, and this one wasn’t an exception. However, every major and minor version of Rails brings some new defaults that can accumulate over time, leaving you with some debt to pay.

Today I want to talk about the JSON serializer for cookies that became the default starting with Rails 7.0.

Marshal vs JSON

So what’s up with the new JSON serializer? The previous cookie serializer conveniently used Marshal to convert any Ruby object into a byte stream and allowed us to store pretty much anything as long as it fit…

Ruby Rogues 

Unfinished Business - RUBY 551

Unfinished technology, unfinished products, unfinished gems, unfinished concepts, unfinished code, unfinished libraries, and more.  In software development, everyone has those projects that never get finished or ever get started.  Luke and Valentino banter about the various aspects of unfinished business, specifically technology ideas – from creating to implementing to fixing to scrapping.

Sponsors


Picks

Ruby Rogues 

Unfinished Business - RUBY 551

Felipe Vogel 

RVTWS

When I started my career switch into software development two years ago, I decided to focus my efforts on Ruby. I did this for a few reasons, but one of them is that Rails offers great “bang for the buck”: there’s a lot that I can build with just Rails, HTML, and CSS.

However, this minimal vanilla stack becomes limiting when two factors come into play:

  1. The MVC architecture of Rails won’t always be enough to keep your code organized. You’ll notice it painfully if your app ever grows beyond a small project.
  2. For your app to feel modern, the frontend will need to act like an SPA (Single-Page…

Making a new acronym…

Remote Ruby 

Aaron & Colleen from Hammerstone

[00:01:36] Colleen and Aaron introduce themselves and tell us what they do.

 

[00:03:04] There was a workshop at RailsConf that Colleen and Aaron had around Advanced Active Record and we learn about the purpose of the workshop. 

 

[00:04:42] We find out what Arel is and what it gives us, and how Laravel handles everything you need but in a different way.

 

[00:09:07] We find out where the query builders are in the process of launching for each side.

 

[00:10:57] Andrew wonders if Aaron used CSS variables to make it customizable or if he went with a manual approach, and Aaron tells us a problem they ran across.

 

[00:12:49] Jason asks if they are able to share the front-end libraries between…

Ruby Together News 

May 2022 Monthly Update

Hello! Welcome to the monthly update. During May, our work was supported by Zendesk, DigitalOcean, Stitch Fix, and many others.

ruby together news

In May, Ruby Together was supported by 36 different companies, including Ruby member Zendesk. On top of that we were supported by 133 developer members. Thanks to all of our members for making everything that we do possible. <3

RubyGems News

This month in RubyGems, we released new versions of RubyGems 3.3.14, 3.3.15 and Bundler 2.3.14, 2.3.15.

The following is a non-exhaustive list of other improvements included in the above releases (see the changelog for further information):

  • fixed a regression causing an error message when an…
Awesome Ruby Newsletter 

💎 Issue 318 - Stack Overflow Developer Survey 2022 Results - bad outlook for Ruby. WDYT?

Martian Chronicles, Evil Martians’ team blog 

Collaborative real-time security: Logux for Akeero

Authors: Aleksandr Slepchenkov, Frontend Developer and Andrey Sitnik, Author of PostCSS and Autoprefixer, Lead Frontend Developer at Evil Martians

It’s great luck when a customer’s project allows our team to rock out working on something truly unique. We continued our series of projects centered on interfaces for professional tools and security tools by jumping into UI design and frontend for Akeero. This is a service for analyzing AWS architecture for vulnerabilities, and we built a collaborative real-time diagram composer. In this article, we focus on the aspects of development surrounding the project’s frontend.

Security architecture audits

Akeero is a cloud security platform and a…

Ruby Weekly 

puts-style developing, without the 'puts'?

🇺🇦 #​609 — June 23, 2022

Read on the Web

Ruby Weekly

rstfilter: VS Code Extension to See Execution Results Line by Line — It’s always interesting to see a new tool from a Ruby core team member, and you might find this one useful if you’re a VS Code user and enjoy a bit of puts/p-style debugging! Reminds us of Quokka in the JavaScript space.

Koichi 'ko1' Sasada

RedisGreen: Secure, Scalable, Full-Featured Redis 7 Hosting — The latest Redis features, instrumented and scaled with the tools teams need as they grow.

RedisGreen sponsor

Rails' Discord Server Now Open to the Public — It’s been a long…

wasabigeek's blog 

Overspecifying Tests - the Employee Report Kata

I paired recently with @andyw8 on the Employee Report kata1, which illustrates how tests become more difficult to maintain if they are “overspecified”. For such an unassuming kata, we found a lot to discuss and ponder about. I found his refactoring particularly interesting and wanted to share it.

What is Overspecifying?

In the context of the kata, a test is overspecified when it unintentionally (or intentionally?) tests more than it should. This couples the test to those additional behaviours, causing the test to fail if those behaviours change. Walking through the kata gives us some great examples, so let’s learn while doing!

The Kata

The instructions are to build a program for a shop…

BootrAils 

Ruby-on-Rails ViewComponents tutorial and examples

What is a ViewComponent and why should you use them?

A ViewComponent is simply a Ruby object and a template. There are five main reasons why you should use ViewComponents!

  1. Single Responsibility: Instead of view-related logic being scattered across the project, all the logic needed for a template is consolidated into a single class.
  2. Ease of Testing: ViewComponents can be unit tested, unlike traditional Rails templates! Another bonus is that these unit tests are typically more than a hundred times faster than similar controller tests.
  3. Explicit Data Flow: Since ViewComponents use a standard Ruby initializer, the data needed to render the template is explicitly known. This is the opposite of…

ViewComponents are ideal for templates that are constantly reused or would benefit from being…

Honeybadger Developer Blog 

A Comparison of Node.js Environment Managers

A nuisance that often crops up when working on JavaScript projects pertains to managing the different versions of the tools needed to build or run a project. This essentially boils down to the fact that different projects have different version requirements for their dependencies. For example, one greenfield project might require the latest version of Node.js due to its use of an experimental feature, while a legacy project might depend on deprecated features that make it unable to run on newer releases.

Installing different versions of Node.js or some other package typically involves uninstalling the current version, followed by installing the version that is needed, and then repeating…

Test Double Blog 

Double Agent Profile: Kyle Adams

Name: Kyle Adams
Designation: Agent 0033
Double Agent Role: Senior Software Consultant
Special Skills: I fight for the users! Tron reference aside, I look for little changes that have a big impact, whether it be on developer experience or on user experience.
Aliases: LinkedIn, GitHub, Twitter, WWW
Location: Indianapolis, IN
Favorite Emoji: 🤖

What impact are you proudest of in your career?

This is interesting because it’s something I’m very proud of, but it’s also something that’s only been used at one company. Though the scope is limited, the company still uses it on a website that has millions of visitors a day.

We were at a conference a number of years back, and they…

Test Double Blog 

Returning to the office is costing you untapped talent

Full-time remote work can make a positive impact on everyone, especially groups of folks who are often untapped talent from historically marginalized communities. And I was never more thankful to already be part of a remote organization than when COVID hit in the spring of 2020. Many companies scrambled to accommodate a remote workforce on top of everything else they were facing. Test Double was not exempt from many of the issues caused by COVID: financial uncertainty, employee stress and burnout, instability around client forecasting, etc. Having to figure out how to change our employees’ work environment and communication practices was—thankfully—not one of those challenges.

Once again,…

Saeloun Blog 

Rails for Multi database defines reading_request? in resolver

Rails 6 had added the support for multiple database connections using which we can configure the separate databases for reads and writes.

For example, we have two databases write_database and read_database.

  /config/database.yml

  default: &default
    adapter: postgresql
    encoding: unicode
    host: <%= ENV['PG_HOST'] || 'localhost' %>
    pool: 5
    username: <%= ENV['PG_USER'] || 'postgres' %>
    password: <%= ENV['PG_PASSWORD'] || 'postgres' %>

  development:
    write_database:
      <<: *default
      database: <%= "write_database" %>

    read_database:
      <<: *default
      database: <%= "read_database" %>

Now, in order to use the above-defined databases, we need…

Blog 

Why Ruby on Rails Is Still a Good Choice in 2022 [UPDATED]

Every year, we’re pelted by articles proclaiming the death of this gem of a framework. And while Ruby on Rails (RoR) is a bit over 15 years old, it’s nowhere close to passing on from the world of programming.

Shopify Engineering - Shopify Engineering 

Introducing ShopifyQL: Our New Commerce Data Querying Language 

Shopify Engineering - Shopify Engineering 

How We Built Hydrogen: A React Framework for Building Custom Storefronts

We’ve been building Hydrogen for more than a year. Here’s a look behind the scenes at how we did it, what we learned from making big bets, and what it was like building a new framework from the ground up on experimental technology.

More

The Ruby on Rails Podcast 

Episode 423: Featuring Some of the Nicest People in Rubydom (Brittany + Nick)

Brittany and Nick took a foray into handheld console gaming before celebrating Nick's new role at Shopify on the Ruby/Rails Infra team. They chatted about their favorite parts of Railsconf including Nick's Ruby Archaeology talk and Shopify's Railsconf Afterparty Twitter Space. Also, Past Rubies is back!

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in monitoring into a single, easy to use platform. Go to Honeybad…

Ruby Magic by AppSignal 

State Machines in Ruby: An Introduction

A state machine can hold all possible states of something and the allowed transitions between these states. For example, the state machine for a door would have only two states (open and closed) and only two transitions (opening and closing).

On the other hand, complex state machines can have several different states with hundreds of transitions between them. In fact, if you look around, you will notice finite state machines surrounding you — when you buy from a website, get a pack of crisps from the vending machine, or even just withdraw money from an ATM.

In this post, we'll look at how to set up a state machine in Ruby and use the state machines gem.

State Machines in Development

When do…

Code with Jason 

152 - Tom Rossi, Co-Founder of Buzzsprout

In this episode, Tom Rossi and I discuss his principles for developing applications, guiding your efforts via mantras, being intentional about culture, providing a safe space for mistakes and questions, understandable code, and how to hire programmers who fit your culture. 

Rails, PostgreSQL Performance Audit and Tuning Consultant for Hire 

5 Easy to Miss Security Best Practices for Web Apps

Worrying about your app’s quantum resistance is a perfectly legitimate concern. But, in this blog post, I’ll take a step back and describe and few simple but easy-to-overlook security tips. In many cases, a single line of config can protect your web application from a range of attacks.

Of course, even having all the described solutions in place does not mean that your app is now secure. But, without them, the scope of a potential attack is significantly larger.

1. HTTP security headers

These headers are usually the first thing that I check when conducting my Rails performance and security audits:

HTTP security headers check

Sample security headers report from securityheaders.com


Most of them don’t have to be…

Island94.org 

I read "Programmed Inequality: How Britain Discarded Women Technologists and Lost Its Edge in Computing" by Mar Hicks

The experience of learning about systemic racism in the US is a constant derailing of “but we can’t know the actual intent”; systemic sexism on the otherhand is “oh, here are the receipts”. Which is not to discount the research and scholarship of author Mar Hicks, more just to say “wow, there it is”.

Programmed Inequality is focused on one particular aspect covered by the more surveyish Recoding Gender. To attempt to summarize a lot:

  • Take a systemic inequality, like the Marriage Bar, which made it unlawful for women to keep their job once they became married.
  • Then it’s reasonable to imagine that managers will invest less time in training and developing women in the workplace.
  • Then…
The Bike Shed 

343: Opt-In To Oversharing

Chris is weathering through a slight lull, a holding period, where his team waits for new features to become available with some of the platforms they integrate with, and as they think out new facets of the platform they're building.

Steph has been thinking recently about working in isolation. It's a topic that Joël Quenneville pointed out to her and mentioned. Can engineers work in isolation and be successful?


Become a Sponsor of The Bike Shed!

Transcript:

CHRIS: Always be singing.

STEPH: I can't remember if I've shared the story with you. But I had a beautiful little human moment with someone at airport security. Because when I travel with my mic, I always get stopped…

DEV Community: Brandon Weaver 

On Autism - Grounding and Normalcy

Most of my writing on autism tends to pertain to software engineering in some regard, and while I cannot separate myself from it in my professional career there are writings which focus more directly on my experience as an autistic man rather than as a software engineer.

Articles in this particular series, versus "Tales of the Autistic Developer", reflect more on my personal life experiences and how my mind works.

To many I pass very well as neurotypical, a mask I've spent years cultivating, but beneath that mask there's quite a bit going on. Some triumphs, some struggles, some just living life honestly but stories nonetheless I occasionally tell and write on and this is one such story.

Honeybadger Developer Blog 

Testing PHP Applications

Lately, there has been a lot of movement around new and exciting php testing tools. While this is great news, stepping back a little and understanding the underlying concepts before jumping in would be helpful. Let's start by agreeing that when we talk about testing tools and methodologies, we're referring to automated testing tools.

What is Automated Testing?

Automated testing refers to using software tools designed specifically to run an application with a particular set of inputs and check the produced output against a known set of expectations. In essence, it's not very different from regular (i.e., manual) testing. It's just way better.

Why is Automated Testing a Good Idea?

Automat…

Island94.org 

Laws of Spacecraft and Software

Lots of similarities between Akin’s Laws of Spacecraft Design and software management; via AJ’s weekly email:

  1. In nature, the optimum is almost always in the middle somewhere. Distrust assertions that the optimum is at an extreme point.

  2. (Shea’s Law) The ability to improve a design occurs primarily at the interfaces. This is also the prime location for screwing it up.

  3. A bad design with a good presentation is doomed eventually. A good design with a bad presentation is doomed immediately.

  4. Capabilities drive requirements, regardless of what the systems engineering textbooks say.

  5. (McBryan’s Law) You can’t make it…




This post, Laws of Spacecraft and Software, is published on Island94.org. Tweet me at @bensheldon to discuss it.

Giant Robots Smashing Into Other Giant Robots 

Connascence as a vocabulary to discuss Coupling

As software engineers, we often discuss complex concepts that might lead to nebulous and endless discussions. Coupling is one of these complex concepts that raise common questions. How harmful is coupling? How can we measure coupling? What are the different types of coupling? Connascence introduces a shared vocabulary for determining different types and the severity of the coupling in our systems, answering these questions, and making discussions around coupling less nebulous and goal-oriented.

What is Connascence

Let’s define the concept of Connascence:

Two pieces of software share connascence when a change in one requires a corresponding change in the other

Connascence…

Island94.org 

I read "Hench" by Natalie Zina Walschots

Hench moves past “but what if superheroes were actually bad?” and into exploring whether one can have superpowers without aligning/performing as a hero (not according to the heroes) and can someone be villaneous without being evil? (open question)

It’s delightful in the Becky Chambers’-style of “let’s (try) to be our best selves while navigating our differences against a backdrop of adversity”. For some moments I felt like I was reading The Phoenix Project to the extent it was describing contemporary professional life …but then drops in a story of using child abuse as a supervisory tactic and that was not enjoyable.




This book review for Hench, is published on Island94.org. …

Code with Jason 

151 - LIVE from Sin City Ruby: Soup with Jason (feat. Nick Schwaderer, Andrew Katz and Kenny Kandola)

In this episode of Soup with Jason, recorded live at Sin City Ruby 2022, I talk with a few friends about topic near and dear to our hearts: soup.

Remote Ruby 

For the love of Sass & Podia's new Free plan

[00:01:18] Bridgetown 1.1 beta is out, we hear what kind of cool stuff it does, and a demo Andrew did for Bridgetown Torchlight.


[00:08:54] Jason brings up Podia’s UI library and the problems they had with it, and Andrew tells him he’s been plotting to pull the library back out. 


[00:12:42] Why does Andrew hate Sass?


[00:15:34] The guys chat about Safari, issues with it, and how they’re getting better. Andrew talks about a Raindrop extension that can also be done on your phone.


[00:17:53] The Sass Movement and CoffeeScript Movement is brought up, and Jason explains why he likes ERB, ES6, and CSS, and Chris talks about JavaScript.


[00:21:29] Chris gives us an update of his house, we find…

Awesome Ruby Newsletter 

💎 Issue 317 - Making popular Ruby packages more secure

Ruby on Rails 

Rails Discord server is now open to the public

In the past few weeks, the Rails team has been working on a few changes to lower the barrier for new contributors to the framework.

We started by disabling the automatic closing of stale PRs. While initially this automation helped the project keep the issues tracker under control, nowadays things are better and we prefer to go back to full human interaction.

To make it easier for contributors to recognize all the members of the Rails team, we made public the list of current members of the Issues team. The Issues team assists with issues triage, pull request reviews and documentation improvements, so they are often the first interaction users have with the Rails team.

Today, we are…

Ruby Weekly 

Does your gem have over 165 million downloads? Well..

🇺🇦 #​608 — June 16, 2022

Read on the Web

Ruby Weekly

Making Popular Ruby Packages More Secure — Mirroring similar moves by GitHub with the npm registry, RubyGems’ maintainers want to improve the security of the Ruby ecosystem by making maintainers of the most popular gems use multi-factor authentication on their RubyGems accounts to mitigate account takeovers. How popular? “Anybody who maintains a gem with more than 165 million downloads”.. 😮

Betty Li (RubyGems)

Why attr_accessor is Faster than Regular Methodsattr_accessor, attr_writer and attr_reader are just shorthand for defining getter and setter…

Martian Chronicles, Evil Martians’ team blog 

How to make absolutely any app look like a macOS app

Authors: Anton Lovchikov, Interface Designer / Product Designer and Travis Turner, Tech Editor at Evil Martians

What makes a native macOS app …look like a native macOS app? In this article, we’ll analyze this question and look at some practical ways you can adopt the design conventions of macOS apps in your own apps. You’ll be able to make design decisions so that your apps fit right in, thus, offering a more seamless experience as well as other potential benefits—read on!

Although this article deals primarily with the “native macOS look”, it’s important to note at the outset that many of the features and concepts below also apply to Windows apps. And further, it’s also worth…

Ruby Rogues 

Kafka and Karafka Integrations with Maciej Mensfeld - RUBY 550

Making his second appearance on the podcast, Maciej Mensfeld joins the show to share his latest developments with his Kafka and Karafka integrations and libraries. He shares his framework for Kafka 2.0, his personal approach to Rails, and how to integrate Kafka and Karafka most effectively. The panel also discusses regulation and security risks with open-source libraries for developers.

About this Episode…

  1. What is Kafka and Karafka and how are they used?
  2. The Rails mindset with Kafka and Karafka vs. batches
  3. What is making Karafka faster?
  4. Open-source libraries and regulation and security risks

Sponsors

Links

Honeybadger Developer Blog 

Everything You Need to Know About Caching in Django

Have you ever wondered what caching is and if it can be done with Django? Would you like to demystify the whole concept of caching in Django? If you have been asking these questions, then you are in luck!

In web development, caching is a layer that stores data that are fetched often so that future requests are provided faster then when trying to access that data from the primary database. By caching, you are trading off capacity for speed. Unlike the primary database that contains all the data, cached data is only a subset of the data stored in the database.

In this article, I will explore scenarios in which you may want to implement caching, as well as the different tools and ways you…

Honeybadger Developer Blog 

Incident Management for Status Pages

Whether you need to let your users know of upcoming downtime for system maintenance or something more serious like a multi-week security incident, public status pages are awesome for building transparency and trust with your users. That’s why we are excited to announce our newest status page feature: incident management!

Incident management lets you report an incident in real time, schedule an alert for upcoming maintenance, or retroactively insert an update for a past incident. Each report includes the status of the incident, the severity, as well as a description field to tell your users exactly what to expect.

You can also connect your Twitter account to notify your followers…

Shopify Engineering - Shopify Engineering 

Making Open Source Safer for Everyone with Shopify’s Bug Bounty Program

Zack Deveau, Senior Application Security Engineer at Shopify, shares the details behind a recent contribution to the Rails library, inspired by a bug bounty report we received. He'll go over the report and its root cause, how we fixed it in our system, and how we took it a step further to make Rails more secure by updating the default serializer for a few classes to use safe defaults.

More

RubyGems Blog 

3.3.16 Released

RubyGems 3.3.16 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:

  • Auto-fix and warn gem packages including a gemspec with require_paths as an array of arrays. Pull request #5615 by deivid-rodriguez
  • Misc cargo builder improvements. Pull request #5459 by ianks
  • Installs bundler 2.3.16 as a default gem.

## Bug fixes:

  • Fix incorrect password redaction when there’s an error in gem source -a. Pull request #5623 by deivid-rodriguez
  • Fix another regression when loading old marshaled specs. Pull request #5610 by deivid-rodriguez

SHA256 Checksums:

  • r…
The Ruby on Rails Podcast 

Episode 422: Object Shapes and Open Source (Brittany + Jemma)

Brittany had questions about how to contribute to Ruby but luckily, Jemma was here to explain the process and explain her most recent proposal: Object shapes for Ruby. Object shapes are a technique for representing properties of an object. The two then debate reaching sustainable open source software.

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in monitoring into a single, easy to use platform. Go to Honeybadger.io and…

Saeloun Blog 

Rails 7 extends audio_tag and video_tag to accept Active Storage attachments

ActiveStorage provides an easier way to upload and store the files on various cloud services.

Rails also provides easy way to embed them using the appropriate tags. For example,

  • image_tag
  • audio_tag
  • video_tag

In this article we will see how to embed the ActiveStorage files and what’s changed in the latest update.

Let’s take an example of a Movie model. Our Movie model has various attributes title, duration, etc. The model also has several attachments poster, title_song and trailer

class Movie < ApplicationRecord
  has_one_attached :poster      # Image
  has_one_attached :title_song  # Audio
  has_one_attached :trailer     # Video
end

Before

Before 7.1, we could pass…

Ruby Rogues 

Kafka and Karafka Integrations with Maciej Mensfeld - RUBY 550

Making his second appearance on the podcast, Maciej Mensfeld joins the show to share his latest developments with his Kafka and Karafka integrations and libraries.  He shares his framework for Kafka 2.0, his personal approach to Rails, and how to integrate Kafka and Karafka most effectively.  The panel also discusses regulation and security risks with open-source libraries for developers.

About this Episode…

1. What is Kafka and Karafka and how are they used?
2. The Rails mindset with Kafka and Karafka vs. batches
3. What is making Karafka faster?
4. Open-source libraries and regulation and security risks

 Sponsors

Links

DEV Community: Brandon Weaver 

ASTs in Ruby - Node Pattern and Introducing RuboCop

In the last article I was not being quite honest when I said that regex would not work when trying to manipulate Ruby files. Strictly speaking, no, regex is not a good idea for working with tree-like structures and tokens but there is something there we need to take a look at.

Regexp stands for Regular Expressions, or in the way I tend to define it a set of expressions that can describe the shape of text in such a way you can match against anything with a similar shape. We could be pedantic and go into regular languages, but let's instead focus on this part:

describe the shape of text

Who's to say we couldn't have an expression language of some sort that would match against other shapes,…

Ruby in Better Programming on Medium 

Elixir in Real Life

My perspective after working with Elixir (and Phoenix) in a real production environment.

Test Double Blog 

Understanding the Law of Demeter

The Law of Demeter, simply stated, says that an object should not “reach through” its collaborators to access their collaborators’ data, methods, or collaborators.

The name of the law references the name of the project the authors were coding when they coined it. The authors named the project “Demeter”, which itself is a reference to a hardware description language called “Zeus”. Demeter, the goddess of harvest and agriculture, is a sister of Zeus.

Perhaps the easiest way of describing how to obey the Law of Demeter is to give an example of disobeying it. Here, our Ranger accesses dwarf.strength.modifier and dwarf.proficiencies.include?, both of which are violations of the Law:

class Rang…
Giant Robots Smashing Into Other Giant Robots 

It's official - RSpec Training

Here at thoughtbot, we’re so passionate about Test-Driven Development (TDD) that we wrote a book about it! Now, don’t get me wrong: books are great for learning at your own pace. But we also know that the best learning can happen when you’re working directly with your teammates on real codebase problems.

That’s why we’re pleased to announce thoughtbot’s new service: customized RSpec Training. Whether your team are RSpec newbies or testing pros, we’ll begin by assessing your Rails codebase and interviewing your team to identify standards, pain points, and improvement opportunities. We then translate these into a remote-training curriculum, tailored to your team and product’s needs.

Shopify Engineering - Shopify Engineering 

How We Built Shopify Party

Shopify Party is a browser-based internal tool that we built to make our virtual hangouts more fun. With Shopify’s move to remote, we wanted to explore how to give people a break from video fatigue and create a new space designed for social interaction. Here's how we built it.

More

Code with Jason 

150 - Urban Hafner

This week, I'm joined by Urban Hafner for a wide-ranging discussion on management roles, autism, programming organization structure, sci-fi and fantasy books, programming books, the reasons behind high developer turnover, and bass guitar.

Saeloun Blog 

Rails allows specifying the maximum number of records that will be destroyed in a single background job.

Rails 6 had added the :destroy_async option to delete the associated records in a background job whenever the foreign_key constraint would be disabled.

But what if the associated records are too large? In this case, by default, the single background job will delete all of them and that can be time-consuming. To handle this, and make it fast, Rails now allows adding the active record configuration to specify the maximum number of records that will be destroyed in a single background job and enqueue additional jobs when the number of records exceeds that limit.

Example:

Suppose we have a Product model and a Review model.

  # product.rb
  class Product < ApplicationRecord
RubyGems Blog 

May 2022 RubyGems Updates

Welcome to the RubyGems monthly update! As part of our efforts at Ruby Central, we publish a recap of the work that we’ve done the previous month. Read on to find out what updates were made to RubyGems and RubyGems.org in May.

RubyGems News

This month in RubyGems, we released new versions of RubyGems 3.3.14, 3.3.15 and Bundler 2.3.14, 2.3.15.

The following is a non-exhaustive list of other improvements included in the above releases (see the changelog for further information):

  • fixed a regression causing an error message when an incompatible Ruby version is used - #5525.
  • fixed an issue with inline mode install output printing information about previously locked gems - #5529, #5530.
DEV Community: Brandon Weaver 

ASTs in Ruby - Pattern Matching

Have you ever wanted to edit Ruby code programmatically? Perhaps change one bit of text to another, use a bit of regex and all good to go. The problem is Ruby code isn't text, strictly speaking, it's a series of tokens that all have distinct meaning which makes it very hard to change non-trivial codepaths with regex without committing horrible atrocities that would make a Perl programmer proud.

(* Multiple Perl programmers were asked for their opinions on aforementioned regexen, and were indeed proud, horrified, and impressed all at once. It was a good day.)

What is an AST?

Jokes aside, if regex isn't going to cut it we need another way to work with Ruby code programmatically,…

dmitrytsepelev.dev 

Understading why attr_accessor in Ruby is faster than a regular method

Setters and getters (or accessors) are very common in various object–oriented programming languages. Some languages have shortcuts to define them, others require programmers to write them by hand (hi, Java!). Ruby does have these shortcuts: attr_reader generates getters, attr_writer generates setter, and, finally, attr_accessor generates both:

class User
  attr_accessor :email

  # the same functionality:
  def email
    @email
  end

  def email=(value)
    @email = value
  end
end

Writing attr_accessor by hand

Sometimes people who explain metaprogramming use attr_accessor as the example. It’s a convenient way to explain the concept: attr_accessor is a method that sits in the singleton…

BootrAils 

Rails link_to tutorial and examples

Ruby-on-Rails and links

The link_to helper simply builds links. It works not only to guide the user from one page to another, but to include parameters and queries in the redirection path.

Many will think that the link_to helper works exactly as the href when using <a href="URL_path">Go to</a>, but we will now see how the first option is much more efficient when having complex paths. Moreover, link_to will save us from messy interpolations with html and erb such as:

<!-- This works, but... -->
<a href="<%= user_path(@user) %>">My user</a>

As you might already know, the redirection features are included in the view pages of an application, Model-View-Controller architecture, and rely on the…

The Bike Shed 

342: Sky Icing

Another toaster strudel debate?! Plus, the results are in for the most listened-to podcast in the RoR community! :: drum roll ::

Steph has a "Dear Gerrit" message to share. Chris has a follow-up on mobile app strategy.


The Bike Shed: 328: Terrible Simplicity
When To Fetch: Remixing React Router - Ryan Florence
Virtual Event - Save Time & Money with Discovery Sprints


Become a Sponsor of The Bike Shed!

Transcript:

STEPH: thoughtbot's next virtual event "Save Time & Money with Discovery Sprints" is coming up on June 17th, from 2 - 3 PM Eastern. It's a discussion with team members from product management, design and development. From a developer perspective, topics will…

Boring Rails: Skip the bullshit and ship fast |  

Self-destructing StimulusJS controllers

This post is part of Hotwire Summer: a new season of content on Boring Rails!

Sometimes you need a little sprinkle of JavaScript to make a tiny UX improvement. In the olden days, full-stack developers would often drop small jQuery snippets straight into the page:

<script type="application/javascript">
  $(".flash-container").delay(5000).fadeOut()
  $(".items").last().highlight()
</script>

It got the job done, but it wasn’t the best.

In Hotwire apps you can use a “self-destructing” Stimulus controller to achieve the same result.

Self-destructing?

Self-destructing Stimulus controllers run a bit of code and then remove themselves from the DOM by calling this.element.remove().

Let’s…

RubyGems Blog 

Making popular Ruby packages more secure

Doodle of a RubyGem wearing an MFA hat, holding a flag with a checkmark

Attacks on the software supply chain are increasing and our community has not gone unscathed. RubyGems has been affected by supply chain attacks in the past, so it’s important for us to mitigate these risks as much as possible. Recommending stronger security practices like enabling multi-factor authentication (MFA) on popular packages is a first step towards improving the security of the RubyGems ecosystem.

Account takeovers are the second most common attack on software supply chains. The countermeasure against this type of attack is simple: enabling MFA. Doing so can prevent 99.9 percent of account takeover attacks.

As proposed in the MFA rollout RFC, RubyGems is beginning to…

Test Double Blog 

The Beauty of Drudgery

The most challenging class I ever took was an English course taught by Professor Lionel Basney. I entered that class thinking I was a decent essayist; I exited with a handful of Cs, average at best. I also exited a much more thoughtful writer.

Aside from being tough, Professor Basney was also an infamous Luddite—that is, someone who intentionally eschewed technology. I have vivid memories of him clacking away on the typewriter in his office. Basney was friends with another well-known Luddite author, Wendell Berry. Both shared a philosophy that, through Basney’s class, I came to appreciate.

From Berry’s 1988 essay for Harper’s Magazine, “Why I Am Not Going to Buy a Computer," this excerpt…

Ruby Together News 

RailsConf: Home Edition 2022 Speaker Spotlight: Thomas Countz

RailsConf: Home Edition 2022 Speaker Spotlight: A Tech outsider’s picks

RailsConf2022 boasts an exciting variety of tracks and talks that highlight the creativity and interdisciplinary nature of the Ruby community. As a tech sector newcomer, I thought it would be fun to curate a series highlighting talks that immediately captured my curiosity, and get to know their respective speakers a little better. Read on for today’s speaker spotlight…

Title of Talk:

Leveling Up from Planning to Production

Speaker: Thomas Countz

headshot - Thomas Countz.JPG

How Did you get into Ruby?

I was learning how to code from books and resources on the internet. Originally, I was really into Python because I enjoyed the “There should…

Mike Perham 

Coming Soon in Sidekiq, 2022 edition

I just released Sidekiq 6.5 and I’ve got a lot of changes on the roadmap for Sidekiq 7.0. Here’s what’s coming soon so you can plan too. New Transaction-aware Client Sidekiq has long had a “problem” with executing jobs very fast, before any associated transaction has committed, leading to “Cannot find Model id=1234” errors. Sidekiq 6.5 introduced beta support for a new Sidekiq::Client option which will delay all job pushes until the current transaction has committed.
Hanami Mastery newest episodes! 

#22 Hanami Router with TDD

Routing is one of the basic components of any web application. In this episode I'll dig a bit into the Hanami router from the usage point of view, covering why it's great and how to work with it.
The RubyMine Blog : Intelligent Ruby and Rails IDE | The JetBrains Blog 

RubyMine 2022.2 EAP4

RubyMine 2022.2 EAP4 is here! Catch up on all the new features by checking out the previous EAP blog posts.

Below you can find the most notable improvements.

Support for YARD macros

We’re continuing to improve our YARD support. Now RubyMine recognizes YARD macro extensions and provides general coding assistance for them.

Use the Go to declaration action on a macro reference to jump to the corresponding macro declaration. In the main menu, go to Navigate | Declaration or Usages or press ⌘ B (macOS) / Ctrl+B (Windows).

RubyMine allows you to search for usages of a macro declaration by invoking the Find usages action. Press ⌥ F7 (macOS) / Alt+F7 (Windows) or go to Edit | Find Usages | Find…

You can use the Rename refactoring on macros by pressing ⇧ F6 (macOS) / Shift+F6 (Windows). Then, specify a new name for…

Render the YARD documentation to check out the macro data in place…

Honeybadger Developer Blog 

Containerizing an Existing Rails Application

Containerizing software is packaging it into standardized units for ease of development and deployment. Containers bundle together code from your application, along with all of its dependencies. A container can stand alone entirely; it contains a package with your software, a runtime environment, and system libraries. Containers help developers and operations teams ensure that software runs the same, regardless of its environment. By separating code from infrastructure, apps that are "containerized" run the same in a local environment, a test environment, and production.

Docker is one of the most popular platforms for developing and deploying software. Docker packages software as an…