Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Ruby on Rails 

Model Missing Attributes, SQLite Immediate Transactions, and CVV/CVC Parameter Filtering by default

Hi, it’s zzak. This is a short week, but let’s jump in.

Drop Hash#except core extension
Rails 8.0 will be Ruby 3.1 or greater only except natively got added in Ruby 3.0 so this is dead code now.

Introduce ActiveModel::AttributeAssignment#attribute_writer_missing
Provide instances with an opportunity to gracefully handle assigning to an unknown attribute:

class Rectangle
  include ActiveModel::AttributeAssignment

  attr_accessor :length, :width

  def attribute_writer_missing(name, value)
    Rails.logger.warn "Tried to assign to unknown attribute #{name}"
  end
end

rectangle = Rectangle.new
rectangle.assign_attributes(height: 10)
  # => Logs "Tried to assign to unknown attribute…

Add “cvv” and “cvc” as default parameters to filter out in new apps
For new apps, this PR adds cvv and cvc to the defaults for ActiveSupport::ParameterFilter.

Ensure SQLite transaction default to IMMEDIATE mode
This PR updates the SQLite…

Ruby News 

Ruby 3.2.5 Released

Ruby 3.2.5 has been released.

This release include many bug-fixes. And we updated the version of bundled gem rexml to include the following security fix. CVE-2024-39908 : DoS in REXML.

Please see the GitHub releases for further details.

Download

Remote Ruby 

There is no A in JSON

In this episode of Remote Ruby, Jason and Chris dive into the complexities of modern
web development, focusing on the challenges and frustrations with rich text editors,
front-end tools, and the intricate balance between server-side and client-side rendering.
Through their experiences, they highlight the evolving landscape of frameworks like
Rails, React, and Turbo, and express the ongoing need for better abstractions and
conceptual compression in JavaScript. They also touch on the struggles specific to
managing OAuth tokens, implementing reusable UI components, and the desire to
simplify development processes while maintaining productivity for small teams. Hit
download now to hear more!

Honeybadger
zverok's space 

How it became like this? Ruby Range class

Understanding the core class design and usage via its evolution

Years ago, my studies into the Ruby Evolution started with the persuasion that mastering the programming language to express one’s intentions clearly and efficiently may grow significantly by understanding how it evolved and what intentions were put behind its various elements.

Moving back through the history of a change of some element of the language exposes a thinking and consensus process that led to API design. It allows one to internalize its functioning, as opposed to just memorizing the cheatsheets.

To illustrate that, let’s look into one of Ruby’s core classes: Range.

What’s a Range?

range = (1..5)
range.cover?(3)
Saeloun Blog 

Functional Programming In React

Every program or application we create follows a certain style or approach, known as a paradigm.

Functional Programming

Functional programming is a paradigm that emphasizes the use of pure functions and immutable data. This approach leads to cleaner, more predictable code and easier for testing, and a more declarative style of programming.

In contrast to the imperative programming paradigm, which emphasizes changes in state. Key principles of functional programming include:

  • Immutability: Data cannot be changed once created. Instead, new data structures are returned with the necessary changes.

  • Pure Functions: Functions that always return the same result given the…

RubyMine : Intelligent Ruby and Rails IDE | The JetBrains Blog 

How to use Stimulus in your Rails apps with RubyMine

Hello everyone!

The RubyMine team is constantly striving to provide support for new technologies for Ruby and Rails. One of the most exciting recent additions to Rails is undoubtedly Hotwire, so we’ve prepared an overview of this suite of frameworks and a tutorial on how to use the most important Turbo and Stimulus features in your Rails app with RubyMine. This post covers Stimulus; For Turbo, please see our previous blog post.

Hotwire and Stimulus

What is Hotwire?

Hotwire simplifies web development by sending HTML over the wire instead of JSON (hence the name, which stands for “HTML over the wire”). This reduces the amount of JavaScript developers need to write and the…

Awesome Ruby Newsletter 

💎 Issue 427 - Minesweeper in 100 lines of clean Ruby

Ruby Central 

July 2024 Newsletter

Hello! Welcome to the July newsletter. Read on for announcements from Ruby Central and a report of the OSS work we’ve done from the previous month.

In June, Ruby Central's open source work was supported by Ruby Shield sponsor Shopify, AWS, the Sovereign Tech Fund (STF), and Ruby Central memberships from 29 other companies, including Partner-level member Contributed Systems, the company behind Mike Perham’s Sidekiq. In total, we were supported by 189 members. Thanks to all of our members for making everything that we do possible. <3

Ruby Central News

RubyConf 2024 announcements

Get your tickets before Early Bird pricing ends on July 31!

Time to join RubyConf 2024 at the best price is running out! …

Ruby Weekly 

How Ruby's IDE experience continues to improve

#​713 — July 25, 2024

Read on the Web

Ruby Weekly

Major Ruby LSP Enhancements in 2024 So Far — The Ruby Language Server Protocol gem (and VS Code plugin) has been busy this year, adding many, many features and improvements. Stan demonstrates several of these features (in VS Code) along with some coming experimental enhancements to improve your Ruby code editing experiences.

Stan Lo

Memetria: Redis Hosting for Serious Developers — Memetria provides secure, scalable hosting with features that enhance your development experience, including large key tracking and detailed performance metrics. Keep your…

Mem…

Rails Designer 

Inline Save and Add Another with Rails and Hotwire

I recently wrote about how to add a “Save and Add Another” feature in your Rails app. This was based on the UX from Linear.

But another way to do this is how Todoist allows you to add new tasks.

Again, just like with Linear-style, this too, with Rails and Hotwire is straightforward to do.

I assume you have an up-to-date Rails ready and a model and controller set up that makes sense for such a feature. I’ve run rails generate scaffold Task body:text for this example.

The goal of this article is when a new task is created

  • add the task to the bottom of the list;
  • show the form at the bottom of the list.

Set up the basics

I like to start UI’s like these with the bare-minimum.…

Josh Software 

Building a Personal RAG Application for PDF-Based Question Answering

We are in the age of LLMs where everyone wants to use or create LLMs. LLM stands for Large Language Models. There are lots of LLMs available in the market like ChatGPT that everyone uses and other than ChatGPT there are Google’s Gemini, Claude are the LLMs. But everyone uses ChatGPT as it is famous … Continue reading Building a Personal RAG Application for PDF-Based Question Answering
code.dblock.org | tech blog 

Enumerating DigitalOcean Apps with a Deprecated Ubuntu 18 Stack

I use DigitalOcean to run a bunch of apps. It’s working out great.

Yesterday, they sent me an email with a menacing “Ubuntu 18 is no longer supported and so it’s not receiving security updates.” note. To be fair, Ubuntu 18 is very old.

Their email included instructions to go to settings to find out what stack you’re using. Let’s find out what apps use what stack on the command line to save time using doctl.

$ for app_id in $(doctl apps list --no-header | cut -d' ' -f1); \
    do echo $app_id; \
    doctl apps spec get $app_id | yq .features; \
    done

110f5185-5570-444e-819c-9651d574c20c
- buildpack-stack=ubuntu-22
e74dcb40-f10e-4ed1-87e1-0ffadd983cea
- buildpack-stack=ubuntu-18

Shoul…

The Ruby on Rails Podcast 

Episode 520: Backend Accessibility with Hilary Stohs-Krause

In our last episode, we talked about Web Accessibility. But, did you know that there are accessibility concerns on the backend and in our interactions with our teams. Hilary Stohs-Krause joins the show to tell us more about how we can be more accommodating to our teams.

Show Notes
Simple writing
"Disability Impacts All of Us" (CDC) - https://www.cdc.gov/ncbddd/disabilityandhealth/infographic-disability-impacts-all.html
Hemingway Editor - https://hemingwayapp.com/
"Use simple words and phrases" (PlainLanguage.gov) - https://www.plainlanguage.gov/guidelines/words/use-simple-words-phrases/
Contrast Checker - https://webaim.org/resources/contrastchecker/

Have a comment on this…

Ruby Magic by AppSignal 

What's Coming in Ruby on Rails 7.2: Database Features in Active Record

Ruby on Rails is currently in major version 7.1 and rolling towards Rails 8, the next comprehensive new release.

Before Rails 8, though, there’s a significant version that will help bridge the gap: Ruby on Rails 7.2.

In this post, we’ll dive into several noteworthy changes in Ruby on Rails 7.2, focusing on the support for database changes in Active Record.

You'll come away with hands-on opportunities to work with these features.

Let's get started!

Active Record Database-Related Features in Ruby on Rails 7.2

The Active Record object-relational mapper (ORM) supports three open-source relational database management systems: MySQL, PostgreSQL, and SQLite. Active Record is most commonly thought…

All about coding 

Hash value omission - an introduction and some examples

Learn about hash value omission in Ruby, their benefits, examples, and implementation guidelines for more concise code
Evil Martians 

git push --force and how to deal with it

Author: Andrey Novikov, Backend EngineerTopics: Tools, Full Cycle Software Development, Backend Development, Git, Heroku

What to do if you have accidentally force pushed to the wrong git branch: a step by step tutorial.

Ever been in a situation where the wrong Git command has had a chaotic impact on your project's repo? People make mistakes! …but sometimes, these mistakes can cost hours of your team's time. So, in this post, we'll show you how to quickly recover from an unfortunate git push --force.

Rails at Scale 

Mastering Ruby Code Navigation: Major Ruby LSP Enhancements in the First Half of 2024

In the first half of 2024, Ruby LSP has seen significant enhancements, particularly in the area of code navigation, thanks to the advancement of its indexer.

In this post, we’ll dive into the major code navigation enhancements that have been made to Ruby LSP. We’ll also touch on some experimental features that are on the horizon.

NOTE

While the Ruby LSP server (ruby-lsp gem) can be integrated with many editors, all the features in this article will be demoed in VS Code with the Ruby LSP extension on a macOS machine.

Therefore, some of the features may not work the same way in non-VS Code editors, or may require different keyboard shortcuts depending on your development…

Table of Contents

The Bike Shed 

434: Git and GitHub Workflows

It's Calls for Proposals (CFP) season, and in the process of helping our friends and colleagues flesh out their CFPs, we came up with a few questions to help them frame their proposals for success. After learning about the importance of finding your audience and angle of approach for your CFP, we dive into today's main topic – our Git and GitHub workflows. Joel and Stephanie walk us through their current workflows before exploring the differences between main branch and future branch commits. Then, we explore commits editing and why it's okay to make mistakes, commit messages versus GitHub pull requests (PR), what you need to know if you're new to Git, and what you need to…

Evil Martians 

Flying free: a tale of partitioning with canaries in PostgreSQL

Authors: Denis Lifanov, Backend Engineer, Alexander Baygeldin, Backend Engineer, and Travis Turner, Tech EditorTopics: Backend, PostgreSQL

This canary-based partitioning strategy is a safer, more controlled way to handle large-scale database partitioning and query optimization. Get real-time statistics and gradual optimization, reducing the risks with traditional partitioning processes.

We had spent more time than we’d like to admit on a PostgreSQL database partition, it remained untested, and, for logistical reasons, we were unable to do a feature freeze. Then, a breakthrough—and a bird was the word: canary. Canary testing, to be specific. We had such a good experience, we decided to share…

BigBinary Blog 

Configuring the Kubernetes Horizontal Pod Autoscaler to scale based on custom metrics from Prometheus

Some of the major upsides of using Kubernetes to manage deployments are theself-healing and autoscaling capability of Kubernetes. If a deployment has asudden spike of traffic, Kubernetes will automatically spin up new containersand handle that load gracefully. It will also scale down deployments when thetraffic reduces.

Kubernetes hasa couple of different waysto scale deployments automatically based on the load the application receives.TheHorizontal Pod Autoscaler (HPA)can be used out of the box in a Kubernetes cluster to increase or decrease thenumber of Pods of your deployment. By default HPA supports scaling based on CPUand memory usage, served by themetrics server.

While building neetoDep…

RubyGems Blog 

June 2024 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 June.

RubyGems News

In June, we released RubyGems 3.5.123.5.13, and 3.5.14 , and Bundler 2.5.12, 2.5.13, and 2.5.14. These releases bring a series of enhancements and bug fixes designed to improve the overall developer experience with RubyGems. Notable improvements include: an improvement to auto-switch to the locked Bundler version even when using binstubs, a fix for duplicated config keys generated when the fallback_timeout URI option is used, and a fix for slow and…

Saeloun Blog 

CSS units rem, em, px, vh, vw, percentage

CSS units are used to style the HTML elements by specifying the size, position, and other properties of HTML elements. There are several types of CSS units like rem, em, px, vh, vw, percentage and each with its own specific use case.

CSS units can be broadly categorized into two main types: absolute units and relative units. Each type has specific use cases and characteristics.

Absolute Units

Absolute units are fixed and do not change based on other elements or the viewport. They provide exact measurements.

  • px (pixels): Represents a single dot on the screen.
  • cm (centimeters): Represents a centimeter.
  • mm (millimeters): Represents a millimeter.
  • in (inches): Represents an inch.

Relative Units

Relative units, on the other hand, are providing flexibility…

GoRails Screencasts 

Adding Honeybadger Insights To The RubyGem

Honeybadger's new Insights feature is awesome but required manually editing the yaml file to enable. Let's make a pull request to automate this.
Matt Stuchlik 

Counting Bytes Faster Than You’d Think Possible

Summing ASCII Encoded Integers on Haswell at the Speed of memcpy turned out more popular than I expected, which inspired me to take on another challenge on HighLoad: Counting uint8s. I’m currently only #13 on the leaderboard, ~7% behind #1, but I already learned some interesting things. In this post I’ll describe my complete solution (skip to that) including a surprising memory read pattern that achieves up to ~30% higher transfer rates on fully memory bound, single core workloads compared to naive sequential access, while apparently not being widely known (skip to that).

As before, the program is tuned to the input spec and for the HighLoad system: Intel Xeon E3-1271 v3 @…

Rails Designer 

5 UI Components Libraries for Ruby on Rails (in 2024)

Over the past ten years many (HTML/CSS) UI components libraries have been launched. The last couple of years, with the rise of JavaScript frameworks, many newly-launched are now focused on solely on those (eg. React).

But there are still plenty of solid UI components libraries for Ruby on Rails apps. I’ve listed those here along with my professional opinion on them as a Rails Product Engineer with over a decade of experience. Important note: I’m also the creator of Rails Designer, the first professional-designed UI components library for Rails.

Bootstrap

Let’s start with probably the most known library of them all: Bootstrap. There are probably few Rails developers who haven’t used it at…

a-chacon 

I Turned My Website into a Jekyll Theme

My previous website was causing complications every time I needed to make graphical modifications, as there was a lot of repeated code, many duplicated pages due to Polyglot, and features I wanted to renew. So I started by creating a Jekyll theme based on my website. I also wanted to contribute to the community, so I hope this theme will be useful to others.

Awesome-jekyll-theme

This is a theme that includes a clean and minimalist design, with versatile layout options and consistent navigation. It’s responsive, adapting well to different devices, and organizes blog content by categories for better site structure.

Just like my website, I built it with TailwindCSS, so some of the code was…

Dhaval Singh's Blog 

Notes on evals in LLM-based applications

A big lesson I've learned while building LLM-based applications: "Unless you have a closed feedback loop, nothing you do will be good enough" Allow me to explain. When building an LLM app, I constantly found myself chasing 100s of different optimizat...
Everyday Rails 

Testing with RSpec book updates for July 2024

Finally, here's the first release of my RSpec testing book, updated for the latest Rails stack!
Boring Rails: Skip the bullshit and ship fast |  

Event sourcing for smooth brains: building a basic event-driven system in Rails

Event sourcing is a jargon filled mess that is unapproachable to many developers, often using five dollar words like “aggregate root” and “projections” to describe basic concepts.

While the high standards of “full event sourcing” might recommend building your entire application around the concept, it is often a good idea to start with a smaller, more focused area of your codebase.

I was familiar with the broadest strokes of event sourcing, but it always felt way overkill for me and something that involved a bunch of Java code and Kafka streams and all of the pain that comes with distributed, eventually consistent systems.

But lately I have been building with a very basic, dumbed down…

Hotwire Weekly 

Week 29 - New Turbo releases, Turbo Native without Turbo?, 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

Turbo Native without Turbo? - Dom Christie explores creating native-like navigation experiences in mobile apps using htmx and Inertia.js as alternatives to Turbo. With that he also published two experimental libraries that go along with it: turbo-shim and turbo-native-htmx-driver.

Custom Color Schemes with Rails - Ross Kaffenberger published an article on the Joy of Rails website and demonstrates how to implement custom color schemes in Ruby on Rails using CSS variables, Hotwire, and SQLite.

Add a “X is…

Ruby Rogues 

Navigating SQL Data Changes: Tools and Techniques for Data Recovery - RUBY 645

In today's episode, Valentino is joined by Evgeny Li, a seasoned software developer and founder of Bemi, to delve into the complex world of data recovery and auditing within SQL databases. They explore advanced solutions like paper trail and refi for querying historical changes, point-in-time recovery features offered by cloud-managed databases, and the use of AI to humanize data structures and enhance monitoring.
They highlight the critical role of Change Data Capture (CDC) in tracking and troubleshooting data changes, with real-world applications across logistics, healthcare, and more. They also discuss the pros and cons of different CDC implementations—query-based, trigger-based, and…
Closer to Code 

The librdkafka Supply Chain Breakdown: rdkafka-ruby’s Darkest Hour

Opening Note

We all make mistakes, and fundamentally, the havoc caused by this incident was due to a flaw in the design of rdkafka-ruby. While the disappearance of librdkafka from GitHub was unexpected, this article aims to clarify and explain how rdkafka-ruby should have prevented it and what was poorly designed. By examining this incident, I hope to provide insights into better practices for managing dependencies and ensuring more resilient software builds for the Ruby ecosystem.

Incident Summary

On July 10, 2024 15:47 UTC, users of the rdkafka gem faced issues when the librdkafka repository on GitHub unexpectedly went private. This break in the supply chain disrupted installations,…

Dom Christie 

Turbo Native without Turbo?

Native navigation with web content is a popular approach to building mobile apps. It’s used by some of the biggest companies in the world, including BBC and Amazon.

37signals have open-source adapters using this idea, enabling web apps that use Turbo on the front-end to create native navigation experiences on iOS and Android. These depend on Turbo, but what if you prefer another client-side library, such as htmx, or Inertia.js?

Turbo’s process is quite straightforward: intercept link clicks, fetch the content, and render the new content. This forms the concept of a Turbo Visit. Turbo triggers Visit lifecycle events that are sent to the native adapter, which then can update the navigation…

Ruby on Rails 

Add non-null modifier for migrations, default script folder and generator, sessions generator and much more!

Hey everyone, Happy Friday! Vipul here with the latest updates for This Week in Rails. Let’s dive in.

Add a basic sessions generator
This change adds a new sessions generator to give a basic start to an authentication system using database-tracked sessions.

# Generate with...
bin/rails generate session

# Generated files
app/models/current.rb
app/models/user.rb
app/models/session.rb
app/controllers/sessions_controller.rb
app/views/sessions/new.html.erb
db/migrate/xxxxxxx_create_users.rb
db/migrate/xxxxxxx_create_sessions.rb

Add script folder and generator
This Pull Request adds a new script default folder to hold one-off or general purpose scripts, such as data migration scripts,…

The new script…

Josh Software 

An Ode to Technology Freedom – Is Over-dependence on Core Products a Boon or a Bane for Banks

With digital transformation at its peak, banks’ reliance on core banking products for seamless integrations and management of core banking functions has been ever increasing (which includes but not limited to traditional Current Account Savings Account services, loans etc). It is true that core banking technology is crucial for banks to stay tech-savvy and relevant … Continue reading An Ode to Technology Freedom – Is Over-dependence on Core Products a Boon or a Bane for Banks
Saeloun Blog 

Understanding Controlled And Uncontrolled Components In React

One of the key concepts in React is how to manage form elements and their state. This is typically done using either controlled or uncontrolled components. Understanding the differences between these two approaches is crucial for building effective and maintainable React applications.

Controlled components

Controlled components are those where React handles the form data through its state.

This means that form data is maintained in the component’s state and changes to the form data are handled by event handlers in React. Whenever the user interacts with the input, the component’s state is updated, and React re-renders the component to reflect the new state.

Here’s an example of a…

Jardo.dev: Blog 

The Rubby Game v0.1

A while back, I picked up a copy of JitterTed’s TDD Game. The game models TDD’s inner loop. You follow the process of figuring out what the code should do, finding a way to test whether it did it, writing the test code, making correct predictions about the compilation and test failures, writing the production code, getting the test passing, and committing the work. It allows you to cut corners for short term advantages at the risk of wasting your efforts in the medium term. This got me thinking; what other programming ideas can we teach with board games?

I immediately started brainstorming ideas for a board game centred around Ruby, Rails, and testing. The ideas flowed quickly. Players…

RubyGems Blog 

3.5.16 Released

RubyGems 3.5.16 includes enhancements, bug fixes and performance.

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.16 as a default gem.

## Bug fixes:

  • Fix gemspec require_paths validation. Pull request #7866 by deivid-rodriguez
  • Fix loading of nested gemrc config keys when specified as symbols. Pull request #7851 by moofkit

## Performance:

  • Use caller_locations instead of splitting caller. Pull request #7708 by nobu

SHA256 Checksums:

  • rubygems-3.5.16.tgz
    7fd10de9e5e933321b62b8f1194256ae64703ba2541cab91ec31244a018d9012
  • rubygems-3.5.16.zip
    8856502100771…
Awesome Ruby Newsletter 

💎 Issue 426 - Ruby methods are colorless

avdi.codes 

Where is the programmer inspo?

Programming is widely regarded, at least among enthusiasts, as a creative act. Calling it a “craft” has gained widespread acceptance, and it’s not unusual to hear the term “art” thrown around (if sometimes a tad flippantly).

And yet, there’s something I see other self-identified “creatives” doing which seems almost entirely absent from the software field. It’s the act of explicitly and deliberately seeking and spreading inspiration.

Writers join groups that throw out daily “writing prompts”. Artists, designers, models and photographers join Pinboard groups and Tumblrs and all manner of forums that share images strictly for the sake of inspiration. In the world of electronic music,…

Evil Martians 

OKLCH in CSS: why we moved from RGB and HSL

Authors: Andrey Sitnik, Author of PostCSS and Autoprefixer, Principal Frontend Engineer, and Travis Turner, Tech EditorTopics: Frontend, Design, OKLCH, CSS, PostCSS

CSS Color Module 4 adds oklch(), and we gain P3 wide-gamut support, boost code readability, and improve developer-designer communication.

The new CSS Color 4 specification has added the new oklch() notation for declaring colors. In this post, we explain why this is important for design systems and color palettes.

Ruby Weekly 

Here's how IRB's getting better

#​712 — July 18, 2024

Read on the Web

Ruby Weekly

IRB and Rails Console Enhancements in 2024 So Far — The last six months have brought a much-improved help system, a new extension API (so you can write your own IRB commands), a better show_source, easier debugging, and some Rails console improvements, such as showing your environment in the prompt. Be sure to have the irb gem in your Gemfile.

Stan Lo

Is AI Just Hype for Your Business? — Many are exploring AI, but few are realising its full potential. Let's turn your AI vision into a tangible solution. Our AI expert can quickly assess your idea & create…

Rails Designer 

Add a “X is writing…” with Rails and Turbo

Apps that rely heavily on text messaging (like Slack, Whatsapp and Telegram) often implement some kind of indication or status if the other party (in the chat room) is typing.

This kind of UX might be useful for engagement or set expectations. Based on your app, seeing the other is typing might keep them around longer. Or it might keep them from adding another message, until you got the message the other was typing.

Luckily for us Rails developers, with the release of Hotwire, this is pretty straightforward to add. Let’s dive in.

I assume you already have some sort of messaging/chat system in place. If you don’t check out the video on hotwired.dev where DHH himself builds a basic chat app

What is needed?

  1. Tweak the New Message form
  2. Create a Stimulus…
The Rails Changelog 

025: Rails, Compilers & Profilers with Aaron Patterson

As you'd expect, any conversation with Aaron inevitably involves Ruby, Rails, compilers, and profiling. In this episode, we delve into all these topics. Enjoy!

Rails at Scale 

Mid-Year Review: IRB and Rails Console Enhancements in the First Half of 2024

As a core part of the Ruby ecosystem, IRB (Interactive Ruby) is an invaluable tool for developers. With its rapid pace of changes and improvements, staying up-to-date with the latest features can significantly enhance your development workflow. In this post, we’ll cover the significant updates to IRB from the first half of 2024 (between v1.11.0 and v1.14.0), as well as enhancements in the Rails Console.

(You can also read the improvements we made prior to v1.11.0 in my previous article, “Unveiling the big leap in Ruby 3.3’s IRB”.)

NOTE

To upgrade IRB, you can simply install it as a gem by adding gem "irb" to your Gemfile.

What’s New

Saeloun Blog 

Rails Adds SKIP_TEST_DATABASE_TRUNCATE Flag To Speed Up Multi Process Test Runs

Testing is a crucial part of the development process, especially in large Rails applications with extensive databases.

However, running a comprehensive test suite can often be time-consuming, particularly when dealing with multiple processes and a significant number of database tables.

Why Database Truncation Slows Down Tests

Rails truncates (clearing out) the tables in our test database before running tests to ensure that each test starts with a clean state, free from any data left over by previous tests.

While this ensures test isolation, it can also introduce significant overhead with unnecessary truncation operations especially in applications with a large number of tables.

For…

Ruby Magic by AppSignal 

An Introduction to Auth0 for Ruby on Rails

From custom-made to plug-and-play forms of authentication, Ruby developers have plenty to choose from these days. Yet, as you may know, building your own solution can be costly and dangerous. If Devise is the de facto standard for most teams, an alternative might simplify the lives of most.

This article will cover the setup and use of Auth0 in a Ruby on Rails application, including everything you need to get going properly, from handling roles to relying on multiple providers to authenticate users.

Getting Started

Here's what we need to get started:

  • An Auth0 account
  • A Ruby on Rails application (version 7.x onwards)

Auth0 is a third-party authentication service with a free tier that lets…

Josh Software 

Rest Assured Framework: A Guide to Using Cucumber/BDD and Java Language

Welcome to the world of seamless REST service testing with Rest Assured! If you are a developer or automation engineer seeking a reliable solution to validate RESTful APIs, you have come to the right place! Rest Assured is not just another testing tool. It is an open-source Java DSL designed to simplify the testing process … Continue reading Rest Assured Framework: A Guide to Using Cucumber/BDD and Java Language
Graceful.Dev 

Site News #20: Return of the Endless

Hi there graceful devs! Look, we’re back on a monthly newsletter schedule! Let’s see how long we can keep it up.

Content Updates

There’s one new episode up since the last update: Endless Method in Ruby. The next installment in Noel Rappin’s series on modern Ruby features, this one covers how, why, and when to use Ruby 3’s shortcut syntax for one-liner methods.

What’s your favorite Ruby feature that has been introduced since you started using the language?

Site Improvements

Things have been pretty stable around the garden lately. In lieu of new features, here’s a reminder that Graceful.Dev has forums! They’ve been a little quiet, but they don’t have to be.

To prime the…

Karol Galanciak - CTO and co-founder of Smily, Distributed Systems Architect and Ruby on Rails expert 

Beyond the Engineering: How Tech Executives Can Collaborate With Other Business Leaders to Prevail Over Technical Debt

In the previous article, I focused on technical debt as a crucial concept not merely in the engineering domain but in multiple business areas and how effective communication and speaking the language of other stakeholders is critical for successfully dealing with it. This time, let’s dedicate more time to collaborating with other executives and business leaders and how they could get a solid understanding of the subject and contribute substantially to the resolution of the problem and even become advocates of the initiative.

To avoid generalization and be more specific, let’s pick the CFO as the example hero executive for this article. Many KPIs can be translated to financial metrics with…

BigBinary Blog 

Rails 7.2 makes counter_cache integration safer and easier

Counter caches are a cornerstone of performance optimization in Railsapplications. They efficiently keep track of the number of associated recordsfor a model, eliminating the need for frequent database queries. However, addingcounter caches to existing applications, especially those with large tables,often can be challenging. Rails 7.2 brings an exciting update to address justthat!

Counter cache integration challenges

When introducing counter caches to large datasets, developers often encountertwo primary challenges:

  • Backfilling data efficiently: Adding a counter cache column to an existingtable with a substantial amount of data can be problematic. Backfilling thecounter cache values…
Planet Argon Blog 

Planet Argon Named One of Inc. Magazine's Best Workplaces of 2024

Planet Argon Named One of Inc. Magazine's Best Workplaces of 2024

Planet Argon has been named one of Inc. Magazine's Best Workplaces in 2024 for the second consecutive year! This honor highlights our commitment to a collaborative and value-driven work culture.

Continue Reading

RubySec 

CVE-2024-39908 (rexml): DoS in REXML

There is a DoS vulnerability in REXML gem. This vulnerability has been assigned the CVE identifier CVE-2024-39908. We strongly recommend upgrading the REXML gem. ## Details When it parses an XML that has many specific characters such as <, 0 and %>. REXML gem may take long time. Please update REXML gem to version 3.3.2 or later. ## Affected versions REXML gem 3.3.2 or prior ## Credits Thanks to mprogrammer for discovering this issue. ## History Originally published at 2024-07-16 03:00:00 (UTC)
Evil Martians 

How to make complex Chrome extensions: a zero gravity guide

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

Building a complex browser extension isn't exactly easy, so use this guide and float to success!

Building a complex browser extension isn’t exactly easy—especially for first-timers or folks who feel unsure of what they’re doing! Not to worry. We’ll show you the essentials for building a full-featured Chrome extension using a real example from the Evil Martians casebook! We’ll also share some other useful tips and cool recommendations, so read on!

Hanami 

Hanami 2.2.0.beta1

Earlier this year we introduced our view layer with Hanami 2.1. After some intensive months of work, we’re back again and ready to complete the stack! With today’s release of Hanami 2.2.0.beta1, we’re delighted to offer you a preview of our database layer, as well our new tool for organising business logic.

Introducing our database layer

Hanami’s database layer is based on Ruby Object Mapper (ROM), a mature and flexible data persistence toolkit for Ruby.

Our goal for Hanami 2.2 is to provide the world’s best ROM experience, one that feels thoroughly at home within Hanami apps. We want to make it easy for you to get started and enjoy the benefits that come…

Radan Skorić's personal site 

Exercise: Minesweeper in 100 lines of clean Ruby

Ruby is such an expressive language. You can often do surprisingly much with just a few lines of code. It’s why I find it so satisfying to think about how to accomplish the same thing in fewer lines of Ruby1. I want to be clear: I am not talking about Code Golfing, although that can also be fun. I’m talking about reducing the number of lines of code without loosing the readability. In fact, on...
The Bike Shed 

433: Riffing with Kasper Timm Hansen

Have you ever wondered how improvisation can revolutionize coding? In today’s episode, Stephanie sits down with Kasper Timm Hansen to discuss his innovative “riffing” approach to code development. Kasper is a long-time Ruby developer and former member of the Rails core team. He focuses on Ruby and domain modeling, developing various Ruby gems, and providing consulting services in the developer space. He has become renowned for his approach of “riffing” to software development, particularly in the Ruby on Rails framework. In our conversation, we delve into his unique approach to coding, how it differs from traditional methods, and the benefits of improvisation to code development.…

Ruby News 

CVE-2024-39908 : DoS in REXML

There is a DoS vulnerability in REXML gem. This vulnerability has been assigned the CVE identifier CVE-2024-39908. We strongly recommend upgrading the REXML gem.

Details

When it parses an XML that has many specific characters such as <, 0 and %>. REXML gem may take long time.

Please update REXML gem to version 3.3.2 or later.

Affected versions

  • REXML gem 3.3.1 or prior

Credits

Thanks to mprogrammer for discovering this issue.

History

  • Originally published at 2024-07-16 03:00:00 (UTC)

Posted by watson1978 on 16 Jul 2024

Ruby on Rails 

Launch your podcast at Rails World with Buzzsprout

The Rails Foundation has exciting news: After last year’s success Buzzsprout is once again sponsoring the Rails World Podcast program - only this year we are adding a fun new element.

If you’ve always wanted to have your own podcast, now is the time. Buzzsprout, the world’s largest premium podcast hosting platform built on Rails, wants to help you one lucky would-be podcaster launch their podcast at Rails World.

With 1,000 attendees from around the world, and a lineup of some of our industry’s best speakers, it is a unique opportunity for podcasters to meet, interview, and connect with other community members at Rails World - all under one roof.

What does the winning would-be podcast…

Short Ruby Newsletter 

Short Ruby News - Edition #99

Stay up-to-date on the latest launches, events, code samples, videos, and articles in the Ruby world. Don't miss out on what's happening in our community!
Alchemists: Articles 

Git Rebase AutoSquash

Cover
Git Rebase AutoSquash

Git Rebase is my only workflow because it leads to clean Git histories, automatic release notes, improved team/stakeholder communication, leveling up of new team members, and so much more. This is especially true when coupled with Git Lint and Milestoner.

One of many tricks, when rebasing, is to reduce as much manual labor as possible. This article will teach you how to configure Git to use AutoSquash so you can do less work especially when it comes to automatically moving and resolving your fixup!, amend!, and squash! Git directives to the correct location when rebasing. ⚡️

Table of Contents

Quick Start

To quickly…

Evil Martians 

Startups on Rails in 2024: my keynote at RailsConf

Authors: Irina Nazarova, CEO, and Travis Turner, Tech EditorTopics: Business, Full Cycle Software Development

Are startups choosing Ruby and Rails in 2024? Yes, they are! Moreover, they're shipping products faster by switching to Rails from the hyped Next.js and the established Java. Hear these stories in Irina's keynote at RailsConf.

Are startups choosing Ruby and Rails in 2024? Yes, they are! And they’re switching from hyped up Next.js and the established Java—and shipping products faster—with Rails. But these startups also need some things that don’t exist yet! You’ll hear their stories, but first, some context.

Rails Designer 

Create a String to Color Helper with Ruby

In the latest (v1) version of Rails Designer I added a Chat Messages Component.

For one of the provided variants I wanted to have a different background- and text-color based on the user’s name. I like this kind of “random” customizations to UI components, as it gives an otherwise monotone UI layout some sparkle. In the context of chat messages it works well too differentiate between the different messages from users.

I used a similar technique for the AvatarComponent. Here, when no profile picture is available (attached), it calculates the color for the user name’s initial.

I typically calculate these colors at runtime, but I can imagine, when your app grows, to store them alongside the…

Hotwire Weekly 

Week 28 - RailsConf 2024 videos, managing connection avalanches, 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

Connection avalanche safety tips and prepping for real-time applications - Vladimir Dementyev published a post on the Evil Martians blog offering essential tips for managing connection avalanches in real-time applications, covering strategies from operational practices to client-side and server-side solutions.

Swapping out a model div with Turbo Streams and Stimulus - Justin Searls demonstrates how to dynamically update a model div using Turbo Streams and Stimulus in Rails.

Turbo Frames versus Turbo…

code.dblock.org | tech blog 

Fixing Bugs in the OpenSearch API Documentation using API Spec Tests

I’ve previously written about the OpenSearch OpenAPI Specification.

One of the neat features of the API spec repo is a set of declarative YAML integration tests. This turned out to be really useful in fixing bugs in the OpenSearch API reference documentation that is published to opensearch.org.

Here’s how I went about it.

To author tests, I started with reading the API documentation. For example, I read the docs for /_refresh, and added tests for that API in opensearch-api-specification#374.

The basic example that refreshes all indices was easy.

$schema: ../../json_schemas/test_story.schema.yaml

description: Test _refresh.

chapters:
  - synopsis: Refresh.
    path: /_refresh
    meth…
$ npm run test:spec--insecure -- --tests tests/indices/refresh.yaml 

>
Ruby Rogues 

What is a Top 5% Developer? - RUBY 644

The Rogues dive into who are top 5% developers, what they're doing and how to recognize them. They start out discussing how mid-level developers can move up and how developers can grow in more ways that technical skills.


Links

Picks


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

Summing ASCII Encoded Integers on Haswell at the Speed of memcpy

code { font-size: 13px; white-space: pre-wrap; word-wrap: break-word; }

“Print the sum of 50 million ASCII-encoded integers uniformly sampled from [0, 2³¹−1], separated by a single new line and sent to standard input.”

On the surface, a trivial problem. But what if you wanted to go as fast as possible?

I’m currently one of the top ranked competitors in exactly that kind of challenge and in this post I’ll show you a sketch of my best performing solution. I’ll leave out some of the µoptimizations and look-up table generation to keep this post short, easier to understand and to not completely obliterate the HighLoad leaderboard. Still, as far as I know nothing similar has…

Ruby on Rails 

New Rails beta release, immutable option in http_cache_forever and more

Hi, Wojtek here again. See another short list of changes from this past week.

Rails 7.2.0.beta3 have been released
With 91 commits since the last beta 2 version.

Make http_cache_forever use immutable option
The immutable: true option was added to expires_in in last week. This change sets immutable: true option for http_cache_forever which additionally affects proxied Active Storage files.

Do not watch for translation changes from gems
Optimizes the load time for I18n initialization by restricting I18n load paths passed to the file watcher to only those within the applications directory. Previously, the watcher would grab all of the available locales, including those in gems which do not…

Saeloun Blog 

Puma-dev And Using It With Rails Applications.

Puma

Puma is a modern, concurrent web server for Ruby and Rack applications. Designed with speed and simplicity in mind, Puma is known for its ability to handle multiple requests simultaneously, making it a popular choice for serving Ruby on Rails applications in both development and production environments.

Simplify Local Rails Development with Puma-dev

Developing Rails applications locally can be a hassle, especially when we want to run multiple Rails applications on our machine. Doing that with localhost:3000 will get annoying at some point (cookie sharing, changing ports, everyone in the team handling it differently, no HTTPS to test with…).

for example we have to run multiple…

Posts on Kevin Murphy 

Access Request Headers in a Rails Controller

Heads Up 🔗

A coworker presented a failing request spec. They asked if they were passing headers incorrectly in the test.

it "reports to be a teapot when asked to brew coffee" do  headers = { "X-COMMAND" => "brew coffee" }  get drinks_url, headers: headers  expect(response.status).to eq 418end

They wrote the test exactly like I’d expect. But, rather than providing the 418, a 200 OK was the status code. I then looked at the controller this request spec was accessing.

def index  if headers["X-COMMAND"] == "brew coffee"    head 418  end  @drinks = Drink.allend

Nothing obvious caught my attention. But now that I’d been effectively nerd sniped, I had to figure out what was going on.

Heading In For a…

Awesome Ruby Newsletter 

💎 Issue 425 - Rails 7.2 Adds app:update Task to be a Rails Command.

RubySec 

CVE-2024-27090 (decidim): Decidim vulnerable to data disclosure through the embed feature

### Impact If an attacker can infer the slug or URL of an unpublished or private resource, and this resource can be embedded (such as a Participatory Process, an Assembly, a Proposal, a Result, etc), then some data of this resource could be accessed. ### Patches Version 0.27.6 https://github.com/decidim/decidim/commit/1756fa639ef393ca8e8bb16221cab2e2e7875705 ### Workarounds Disallow access through your web server to the URLs finished with `/embed.html`
RubySec 

CVE-2024-27095 (decidim-admin): Decidim cross-site scripting (XSS) in the admin panel

### Impact The admin panel is subject to potential XSS attach in case the attacker manages to modify some records being uploaded to the server. The attacker is able to change e.g. to `` if they know how to craft these requests themselves. And then enter the returned blob ID to the form inputs manually by modifying the edit page source. ### Patches Available in versions 0.27.6 and 0.28.1. ### Workarounds Review the user accounts that have access to the admin panel (i.e. general Administrators, and participatory space's Administrators) and remove access to them if they don't need it. ### References OWASP ASVS v4.0.3-5.1.3
RubySec 

CVE-2024-32469 (decidim): Decidim cross-site scripting (XSS) in the pagination

### Impact The pagination feature used in searches and filters is subject to potential XSS attack through a malformed URL using the GET parameter `per_page`. ### Patches Patched in version 0.27.6 and 0.28.1 ### References OWASP ASVS v4.0.3-5.1.3 ### Credits This issue was discovered in a security audit organized by the [mitgestalten Partizipationsbüro](https://partizipationsbuero.at/) and funded by [netidee](https://www.netidee.at/) against Decidim done during April 2024. The security audit was implemented by [AIT Austrian Institute of Technology GmbH](https://www.ait.ac.at/),
Ruby Weekly 

All the talks from RailsConf

#​711 — July 11, 2024

Read on the Web

Ruby Weekly

Finding Memory Leaks in the Ruby Ecosystemruby_memcheck is a tool that uses Valgrind to dig into, and debug, memory issues in native Ruby gems, an area that has historically been quite hard to work in. Peter looks at an improvement made to Ruby to track memory leaks and how you can use it.

Peter Zhu

💡 While native gems will always be necessary, Sidekiq's Mike Perham stresses why we should minimize our use of them whenever possible and says he won't let Sidekiq use them at all.

Simple, Fast Data Analytics with Postgres + DuckDB — Fast queries of…

Rails Designer 

Rails Designer V1 is here!

6 months and many, many early adopters later, and a long one-month holiday from yours truly, V1 is here! 💃

Rails Designer started at v0.5.1. The versions before that were internal that only I used to built my various, successful SaaS products.

Before the release of 0.5.1, multiple dozen people purchased, for a big discount, Rails Designer without getting immediate access! That was enough validation for me to switch gears and make Rails Designer ready for all of you.

Fast-forward a few months and Rails Designer now sees dozens of new customers every week! Possibly making it my most successful side-project to date. 🤯

With the release of V1, I am also removing the early-adopters discount…

honeyryder 

http-2 1.0.0, a fork’s tale

TL;DR The http-2-next gem has been officially archived, and has been replaced by http-2 (the gem http-2-next was originally forked from) as the only direct dependency of httpx, after being merged back into the latter.

Origin story

The http-2 gem, is a (quote) pure ruby implementation of the HTTP/2 protocol and HPACK header compression. It’s “transport agnostic”, as in, it does not mess directly with sockets, instead accepting byte strings (via conn << bytes), and allowing callbacks to be registered, in order to be called at key moments of an HTTP/2 connection management lifecycle.

# from the README
require 'http/2'

socket = YourTransport.new

conn = HTTP2::Client.new
conn.on(:frame) {|b…

Internally, it handles…

The Ruby on Rails Podcast 

Episode 519: Joel Hawksley on Web Accessibility

Joel is a staff software engineer at GitHub, working on user interface architecture and strategy. For the last several years, he has been part of the team working to improve the accessibility of GitHub.com. He also leads development of the ViewComponent framework. Today, he joins the show to teach us about Web Accessibility

Show Notes
Joel's RailsConf Talk - https://www.youtube.com/watch?v=4j2zlvE_Yj8
WCAG Guidelines - https://www.w3.org/WAI/standards-guidelines/wcag/
Axe Devtools - https://www.deque.com/axe/devtools/
Aria Live - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live

Island94.org 

Notes from Carrierwave to Active Storage

I recently migrated Day of the Shirt, my graphic t-shirt sale aggregator, from storing image attachments with Carrierwave to Active Storage. It went ok! 👍

There were a couple of things driving this migration, though Carrierwave had served me very well for nearly a decade:

  • For budgetary reasons, I was moving the storage service from S3 to Digital Ocean Spaces. I knew I’d be doing some sort of data migration regardless.
  • I was using some monkeypatches of Carrierwave v2 that weren’t compatible with Carrierwave v3. So I knew I’d have to dig into the internals anyways if I wanted to stay up to date.
  • I generally trust Rails, and by extension Active Storage, to be reliable stewards when I…

And I had a couple of requirements to work though, largely motivated because images in Day of the Shirt are the content with dozens or hundreds displayed on a single page:

  • For budget (slash performance), I need to link directly to image assets. No proxying or redirecting through the Rails…
Gusto Engineering - Medium 

Platform Engineering at Gusto: Part 1

You can’t build beautiful apartments without the construction of a solid foundationYou can’t build beautiful apartments without the construction of a solid foundation

Improving customer communications and engineering productivity

Communicating the right message at the right time with the right channel is a critical part of running businesses. Gusto leverages several channels to communicate urgent action items to customers in order for them to run payroll, manage employees, and ensure that their business is running smoothly.

“Those who don’t know history are doomed to repeat it.”

In the past, customers were notified of any required actions primarily through two channels: in-app notifications and emails. When a customer logged into their Gusto account, in-app notifications,…

Rails at Scale 

Finding Memory Leaks in the Ruby Ecosystem

This blog post is adapted from a talk that Adam Hess and I gave at RubyKaigi 2024.

Until recently, Ruby lacked a mechanism for detecting native-level memory leaks from within Ruby and native gems. This was because, when Ruby terminates, it does not free the objects that are still alive or the memory used by Ruby’s virtual machine. This is because the system will reclaim all the memory used anyway, so it’s just extra work that would make Ruby’s shutdown slower. However, this meant that it was impossible to determine whether a piece of memory was leaked or was just not cleaned up.

This meant that it was hard to analyze Ruby applications that suffered from memory leaks, causing them to…

Peter Zhu 

Finding Memory Leaks in the Ruby Ecosystem

Until recently, Ruby lacked a mechanism for detecting native-level memory leaks from within Ruby and native gems. This meant that it was hard to analyze Ruby applications that suffered from memory leaks, causing them to consume increasing amounts of memory until the system runs out and terminates the application. In this blog post, we'll be looking at the RUBY_FREE_AT_EXIT feature, which allows memory leak checkers to find memory leaks in Ruby and in native gems.
RubySec 

CVE-2024-39308 (rails_admin): RailsAdmin Cross-site Scripting vulnerability in the list view

### Impact RailsAdmin list view has the XSS vulnerability, caused by improperly-escaped HTML title attribute. The issue was originally reported in https://github.com/railsadminteam/rails_admin/issues/3686. ### Patches Upgrade to [3.1.3](https://rubygems.org/gems/rails_admin/versions/3.1.3) or [2.3.0](https://rubygems.org/gems/rails_admin/versions/2.3.0). ### Workarounds 1. Copy the index view (located under the path `app/views/rails_admin/main/index.html.erb`) from the RailsAdmin version you use, and place it into your application by using the same path. 2. Open the view file by an editor, and remove `strip_tags` from the title attribute (as shown in GHSA advisory…
BigBinary Blog 

How we fixed app downtime issue in neetoDeploy

We are building neetoDeploy, a compellingalternative to Heroku. Stay updated by following neetoDeploy onTwitter and reading ourblog.

At neeto we are building 20+ applications, and most ofour applications are running in neetoDeploy. Once we migrated from Heroku toneetoDeploy, we started getting 520 response code for our applications. Thisissue was occurring randomly and rarely.

What is 520 response code?

A 520 response code happens when the connection started on the origin webserver, but that request was not completed. This could be due to server crashesor the inability to handle the coming requests because of insufficientresources.

When we looked at our logs closely, we found that all the 520…

Evil Martians 

Connection avalanche safety tips and prepping for real-time applications

Authors: Vladimir Dementyev, Principal Backend Engineer, and Travis Turner, Tech EditorTopics: Backend, Ops, Performance Optimization, Site Reliability Engineering, Full Cycle Software Development, WebSocket, Hotwire, Ruby on Rails

Learn about different strategies for taming a specific case of the thundering herd problem in real-time applications—connection avalanches.

Launching a greenfield application or rolling out a new feature can be like going out into the wilderness: you can never quite be sure what is waiting for you out there (bears, falling rocks …or an avalanche?) With distributed systems, you can face many common problems, and a little awareness and preparedness could be what…

RubyGems Blog 

3.5.15 Released

RubyGems 3.5.15 includes enhancements, bug fixes 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:

  • Installs bundler 2.5.15 as a default gem.

## Bug fixes:

  • Restrict generic arm to only match 32-bit arm. Pull request #7830 by ntkme
  • Protect creating binstubs with a file lock. Pull request #7806 by deivid-rodriguez

## Documentation:

  • Make it clearer that add_dependency is the main way to add non-development dependencies. Pull request #7800 by jeromedalbert

SHA256 Checksums:

  • rubygems-3.5.15.tgz
    d086e1c368fd3cbe04ca0f108459d0142d0d57413ae9e1d2ff4b220ebc8e6b87
GoRails 

How to Extend the Ubuntu Default Logical Volume Partition

Using VirtualBox, I'll often give Ubuntu a certain disk size and only realize later on that it isn't using the full partition size for the disk.

Run these commands to extend the root filesystem to use the full disk:

lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv
df -h

For more details, see: https://packetpushers.net/blog/ubuntu-extend-your-default-lvm-space/

Saeloun Blog 

Rails 7.2 Adds app:update Task to be a Rails Command.

Rails 7.2, has made many improvements to speed the development process. One major change was the conversion of app:update task to a Rails command. This change aligns the app:update task with other Rails generators.

Why we use app:update ?

After updating the Rails version in Gemfile, We need to update all the configuration files that match with the Rails version,

Previously, updating the configurations files was a time consuming process that required manual changes. Now with the changes in app:update command, the process can be customized with flags according to our workflow.

Before

Previously in Rails, the bin/rails app:update was a Rake task. This implementation had its…

Ryan Bigg's Blog 

Debugging Checklist

Above my screen, I have simple reminder: “IT IS ALWAYS TIMEZONES.” It used to be a simple black-and-white sign until my daughter decided it needed to be turned into a brilliant rainbow of a warning.

The sign was put up after experiencing not one but two timezone-related bugs within a relatively close proximity. Periodically, I’ll see something similar crop up like a test failing before 10am, but not after, thanks to the differences between what day of the week it is in UTC vs my local computer (in +1000 or +1100, depending on the day).

In a work discussion yesterday we talked about debugging checklists and I wrote up one with what I could think of. I’m sharing it here as it might be…

The Bike Shed 

432: The Semantics and Meaning of Nil

The term ‘nil’ refers to the absence of value, but we often imbue it with much more meaning than just that. Today, hosts Joël and Stephanie discuss the various ways we tend to project extra semantics onto nil and the implications of this before unpacking potential alternatives and trade-offs.

Joël and Stephanie highlight some of the key ways programmers project additional meaning onto nil (and why), like when it’s used to create a guest session, and how this can lead to bugs, confusion, and poor user experiences. They discuss solutions to this problem, like introducing objects for improved readability, before taking a closer look at the implications of excessive guard clauses in…

Ruby News 

Ruby 3.3.4 Released

Ruby 3.3.4 has been released.

This release fixes a regression in Ruby 3.3.3 that dependencies are missing in the gemspec of some bundled gems: net-pop, net-ftp, net-imap, and prime [Bug #20581]. The fix allows Bundler to successfully install those gems on platforms like Heroku. If your bundle install runs correctly now, you may not have this issue.

Other changes are mostly minor bug fixes. Please see the GitHub releases for further details.

Release Schedule

Going forward, we intend to release the latest stable Ruby version (currently Ruby 3.3) every 2 months after a .1 release. For Ruby 3.3, 3.3.5 is supposed to be released on Sep 3rd, 3.3.6 on Nov 5th, and 3.3.7 on Jan 7th.

If there’s…

Matt Stuchlik 

The Syscall Showdown: CRuby writes files with 40% fewer syscalls than CPython?

We’ve released a new version of Cirron that can now trace syscalls and record performance counters for individual lines of Ruby code, just like it could already do for Python (more here and here). It makes it very easy to quickly inspect what’s happening in any section of your code and even assert what should be happening in tests, for example.

To put it through its paces I’ve compared what syscalls each language uses for several common patterns: File IO, generating random numbers, telling time and even just printing a string.

File IO

Let’s start with something surprising right away. Here are the snippets under investigation, simply writing a string to a file (I’ll be omitting the Cirron…

Julia Evans 

Entering text in the terminal is complicated

The other day I asked what folks on Mastodon find confusing about working in the terminal, and one thing that stood out to me was “editing a command you already typed in”.

This really resonated with me: even though entering some text and editing it is a very “basic” task, it took me maybe 15 years of using the terminal every single day to get used to using Ctrl+A to go to the beginning of the line (or Ctrl+E for the end – I think I used Home/End instead).

So let’s talk about why entering text might be hard! I’ll also share a few tips that I wish I’d learned earlier.

it’s very inconsistent between programs

A big part of what makes entering text in the terminal hard is the inconsistency…

Evil Martians 

Recapping the first Local‑First conference in 15 minutes

Authors: Andrey Sitnik, Author of PostCSS and Autoprefixer, Principal Frontend Engineer, and Travis Turner, Tech EditorTopics: Frontend, CRDT, JavaScript

A recap of the talks and key insights from the first Local-First Conference 2024

Local-first apps keep data locally, only using the cloud to synchronize data between machines (or peer‑to‑peer). This concept has become popular in recent years, and on May 30, 2024, the local‑first community came together for the inaugural Local-First Conference.

RubyMine : Intelligent Ruby and Rails IDE | The JetBrains Blog 

The New UI Becomes the Default in 2024.2

We are happy to announce that we will enable the new UI for all JetBrains IDE users in the upcoming 2024.2 version. We designed the new UI to reduce visual clutter, ensuring easy access to essential features while gradually revealing more advanced functionality as needed. The new UI is clean and modern, providing bigger, easier-to-use controls, a consistent color palette, light and legible icons, increased contrast, and better accents.

Work on the new UI began in 2021. We analyzed the issues with the old UI, carefully worked on solutions, released preview and Beta versions, gathered feedback, and conducted over 10 UX studies.

There was a lot of positive feedback from our users:

T…

Short Ruby Newsletter 

Short Ruby News - Edition #98

Stay up-to-date on the latest launches, events, code samples, videos, and articles in the Ruby world. Don't miss out on what's happening in our community!
Saeloun Blog 

Rails Add ActiveRecord.after_all_transactions_commit Callback

In Rails applications, it is common to perform actions that depend on the successful completion of database transactions. For instance, sending a notification email after a record is updated or triggering a background job.

However, if these actions are initiated within a transaction, there’s a risk they might be executed before the transaction is fully committed.

This can lead to errors such as ActiveJob::DeserializationError or RecordNotFound especially in environments where the job queue is fast but the database might be slow.

Consider a scenario where we confirm a user and want to send a notification email afterwards:

def confirm_user(user)
  User.transaction do
    user.update(conf…
Rails Designer 

Add a custom Tailwind CSS class for reusability and speed

This is another quick article about something I use in every (Rails) app.

I often apply a few Tailwind CSS utility-classes to create smooth transitions for hover- or active-states. I use this one so often that I create a custom smoothTransition class.

So instead of writing transition ease-in-out duration-200 I write smoothTransition. Much smoother!

Typically you’d write a CSS selector within the @layer utilities directive, like so:

@layer utilities {
  .smoothTransition {
    transition-property: all;
    transition-timing-function: ease-in-out;
    transition-duration: 200ms;
  }
}

And this would certainly work just fine. But Tailwind CSS allows you to write custom styles using its…

Drifting Ruby Screencasts 

Tracking Writebook Changes

In this episode, we look at setting up a mechanism to track the changes from an externally developed product. We'll also discuss branching strategies and how to develop your own features on top of Writebook.
Island94.org 

On the importance of Rails code reloading and autoloading

I’ve elevated to “strongly held belief” that code reloading and autoloading is the most important design constraint when designing or architecting for Ruby on Rails.

  • Code reloading is what powers the “make a code change, refresh the browser, see the result” development loop.
  • Code autoloading is what allows Rails to boot in milliseconds (if you’ve designed for it!) to run generators and application scripts and a single targeted test for tight test-driven-development loops.

When autoloading and reloading just works, it probably isn’t something you think about. When code autoloading and reloading doesn’t work or works poorly, as it has on numerous apps across my career and consulting,…

Hotwire Weekly 

Week 27 - Testing Stimulus Controllers, Optimistic UI with Hotwire, 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! 🚀✨

✨ Hotwire.io Updates

The community-driven documentation and resource hub Hotwire.io got a new section to list videos all about Hotwire. Thanks to Andres Urdaneta for this contribution!

If you produced Hotwire-releated videos or know of videos that would make sense to be featured on that page please open a pull request against marcoroth/hotwire.io by adding a new entry to the videos.yml file.

Otherwise, check-out the new videos page. We have more features and ideas planned for that page, so that you can find Hotwire-related videos more…

Dom Christie 

Optimistic UI with Ruby on Rails & Hotwire

This post details a proof-of-concept for optimistic UI. If you want to just browse the source, check out the optimistic-ui-hotwire-rails GitHub repository.

Optimistic UI enhances perceived speed and responsiveness by immediately updating the UI with an expected state before the server's response is received. This approach is used when the application can predict the outcome of an action based on context and user input, allowing for an immediate response to actions.

Pending and Optimistic UI on the Remix Docs

Optimistic UI is tricky for apps that predominantly render their HTML on the server. However, in simple cases where we can reasonably predict the outcome of a user action, we can…

Karol Galanciak - CTO and co-founder of Smily, Distributed Systems Architect and Ruby on Rails expert 

Beyond the Engineering: The Business Risks of Ignoring Technical Debt

As technology companies continue to deliver innovative products, often on very tight deadlines and with limited budgets (especially now, in the post-zero interest rates era), they also accumulate one natural byproduct —the infamous technical debt.

The Real Impact of Technical Debt on Business

Technical debt is the sum of various trade-offs made while building and maintaining the product and all the things that should have been applied to the system but were not. While most seasoned software engineers have a good grasp of technical debt and know how to address it, they would likely invest more time to “pay it down” and take measures to prevent it in the future, but it’s getting more…

Island94.org 

Introducing GoodJob v4

GoodJob version 4.0 has been released! 🎉 GoodJob v4 has breaking changes that should be addressed through a transitionary v3.99 release, but if you’ve kept up with v3.x releases and migrations, you’re likely ready to upgrade 🚀

The README has an upgrade guide. If you’d like to leave feedback about this release, please comment on the GitHub Discussions post 📣

If you’re not familiar with GoodJob, you can read the introductory blog post from four years ago. We’ve come pretty far.

Breaking changes to job schema

GoodJob v4 changes how job and job execution records are stored in the database; moving from job and executions being commingled in the good_jobs table to Jobs (still in good_jobs)…

a-chacon 

ActiveRecord::Enum persisted in a string field. Is it a bad idea?

There was a moment in my applications when I stopped persisting the fields that I was going to define as enums in int fields and started doing it in strings. I made this decision because, on several occasions, I was asked for a database dump for analysis, and whenever they encountered a status field (or any other using enum) with values like 0, 1, or 2, they would end up asking me about its meaning. So, instead of using numerical values that lack meaning and context, I directly changed them to a string that in itself has meaning and provides context.

But a few days ago, I reviewed the documentation again and found a phrase that made me question this:

Finally it’s also possible to use a…

RubyMine : Intelligent Ruby and Rails IDE | The JetBrains Blog 

How to use Turbo in your Rails apps with RubyMine

Hello everyone!

The RubyMine team is constantly striving to provide support for new technologies for Ruby and Rails. One of the most exciting recent additions to Rails is undoubtedly Hotwire, so we’ve prepared an overview of this suite of frameworks and a tutorial on how to use the most important Turbo and Stimulus features in your Rails app with RubyMine. This post covers Turbo; to learn more about Stimulus support, stay tuned for our next blog post.

Hotwire and Turbo

What is Hotwire?

Hotwire simplifies web development by sending HTML instead of JSON over the wire (hence the name: it stands for “HTML over the wire”). This reduces the amount of JavaScript written and sent to…

Ruby Rogues 

Leveraging Ruby for Effective Prompt Engineering and AI Solutions - RUBY 643

 They dive deep into the world of advanced development techniques and tools. In today's episode, Valentino and Scott explore the challenges and breakthroughs in the realm of AI and code generation with a particular focus on Ruby.
Valentino vents about the complexities of prompt engineering, while Scott shares insights on prompt design, function calling for structured output, and the importance of breaking down code for reliability and testing. They highlight the declining effectiveness of prompt tricks and the growing significance of using large language models over fine-tuning.
The conversation delves into the unique advantages of Ruby for rapid prototyping, with Scott Werner, CEO and…
Ruby on Rails 

Configurable compressor for encryption, Rack 3 streaming and more

Hi, Wojtek here. See the short list of changes from this past week.

Add compressor option to Active Record encryption
ActiveRecord::Encryption::Encryptor now supports a :compressor option to customize the compression algorithm used. The default compressor is Zlib (as it was before).

Utilize Rack 3 streaming
Rack 3 introduced several features to enhance how streaming responses are handled, which Rails now benefits from.

Prefer ETag header over Last-Modified for cached responses
Add config.action_dispatch.strict_freshness configuration. When set to true, the ETag header takes precedence over the Last-Modified header when both are present, as specified by the RFC 7232, section 6. Defaults…

Enhance Action View…

Ryan Bigg's Blog 

Separation of data and view layers in React components

In my Apollo Handbook I cover how to use React + Apollo to interact with a GraphQL API. I thought I’d share a pattern from that book that is making working with this library easier, in particular the pattern where we separate the data layer from the view layer of a component.

With Apollo and GraphQL code generator, we get React hooks that we can use in our component. It can be tempting to combine both these layers together in a single component:

const Product = (id: string) => {
  const { data, loading, error } = usePurchaseQuery({ variables: { id } });

  // handle loading + error states...

  const { product } = data;

  return (
    <div>
      <h1>{product.name}</h1>

     …
Awesome Ruby Newsletter 

💎 Issue 424 - JRuby funding at Red Hat stopped – call for sponsors