Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Martian Chronicles, Evil Martians’ team blog 

RubyKaigi 2022: a report from an Evil Martian in Japan

Authors: Sampo Kuokkanen, Head of Evil Martians Japan, and Travis Turner, Tech EditorTopics: Events, Backend Development, Ruby on Rails, Ruby

For Evil Martians' Japanese office, the annual RubyKaigi conference was the perfect chance to meet up with the local Ruby community.

Do you know RubyKaigi? RubyKaigi 2022 was recently held in Tsu, Japan, and the entire Evil Martians Japanese office team attended the conference in person. This article is both a first-timer's report from this awesome Ruby event and is also your chance to get a taste of what the far-east lifestyle is like for Martians engineers!

Rails, PostgreSQL Performance Audit and Tuning Consultant for Hire 

Simple Presenter Pattern in Rails without using Gems

What’s the size of user.rb file in your current project? The default Rails way model-view-controller architecture often leads to a bloated model layer. Presenter pattern is one of the more straightforward ways to slim down your Rails models. It also helps to reduce the logic in the view layer and makes testing easier. In this blog post, I’ll describe how to implement a presenter pattern without including additional gem dependencies.

How not to views

Before we jump into coding our presenters, let’s first quickly discuss the shortcoming of the default approach of model + view. For the sake of this tutorial, let’s assume we want to code a feature displaying a number of unread notifications.

BootrAils 

Ruby-on-Rails authentication tutorial with Devise

Rails authentication

Ruby-on-Rails lack of internal, built-in authentication mechanism is something often claimed by developer for the next Rails version.

Devise seems the go-to, default gem for authentication, despite being heavily discussed on forums (like this Reddit discussion).

For bootrails we have chosen Rodauth, which is really brilliant.

But this article, I will try to present you the functionality of the Devise gem via a common test case: a quick authentication with username and password

Setup an empty Rails app

We assume you are using an Ubuntu Linux distribution with the following installed:

  • ruby
  • rails
  • bundler

So let's create an empty Rails application.

Prerequisites

To…

Short Ruby Newsletter 

👋 Issue #12 - 26 Sep - 02 Oct 2022

If you want a short excerpt of this newsletter containing only some of the images with code, I created one here. But I invite you to read the entire newsletter as it has excellent content 😊.

This edition was created with support from @adrianthedev from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and from @jcsrb, who sent me recommendations to include in the newsletter.


I feel the same 👇

Source: @collin_jilbert on Twitter

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

Here is a Rails console / irb / debugging tip that well-seasoned Ruby developers know for sure. But if you are just starting out 🐣, you might have missed learning it: A real time-saver, huh? 👇✨
Source: @th1agofm on Twitter

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

💡 Rails tip 💡 Active Model can be used to implement form objects, i.e. objects validating and performing actions that don't fit well with a model. They work great for: ✅ Complex operation-specific validations ✅ Calling third-party APIs ✅ Actions that don't fit a model
Source: @gregnavis on Twitter

👉 Kirill Shevchenko shared code…

Drifting Ruby Screencasts 

Hotwire Introduction

Hotwire is an alternative approach to building modern web applications without using much JavaScript by sending HTML instead of JSON over the wire. With Rails 7, we get Hotwire added in by default. In this episode, we look at some of the features with Hotwire and how to use them.
Honeybadger Developer Blog 

A Deep Dive into Active Record Validations

Many activities that used to be done offline can now be done online, from booking flights to opening bank accounts, shopping online, and much more. At the heart of it, we shouldn’t forget that data are powering all these online transactions.

Therefore, to ensure that everything runs seamlessly, the data stored in databases must be of the right quality. However, what is an effective way to ensure data integrity, especially when a big chunk of it is user-generated? This is where data validations are useful.

Ruby on Rails is structured on the MVC architecture. The "M", also called the model layer, is responsible for managing how objects are created and stored in a database. In Rails, the…

Andy Croll 

Time extensions are an unsung hero of Active Support

In Active Support‘s extensions to the core Ruby classes, some of the most useful and plentiful are related to Time.

One of Rails’s founding uses was to provide helpful, reusable methods for regularly performed tasks. In our web applications we‘re often working with times and dates.

Enter the methods from DateAndTime::Calculations. To find out more check out out the API documentation or the DateTime section in the Core Extensions Rails guide.

Familiarise yourself with…

…the extensions to Date:

today = Date.today
#=> Mon, 03 Oct 2022
today.end_of_week
#=> Sun, 09 Oct 2022
today.beginning_of_month
#=> Sat, 01 Oct 2022
today.end_of_quarter
#=> Sat, 31 Dec 2022
today.beginning_of_year
#=>…
Giant Robots Smashing Into Other Giant Robots 

Using a Dependency Graph to Visualize RSpec let

What data is created when I execute this RSpec test? This question is not as straightforward as you might think. Spec files that rely on let often spread these declarations all over the file so you have to scroll around to find them. Additionally, let is lazy so a particular declaration won’t actually be executed unless it is referenced, either directly by your test or indirectly via one of the direct references. And just to make things even harder, there is also let! which is eager and always executes no matter what! 😱

In these situations, I like to use a visual approach with a dependency graph to understand what is going on.

Our test

Consider a test file like this. It has a…

Ruby on Rails 

ERB in YAML keys, performance boosts, a new option for QueryLogs!

こんにちは。I’m Emmanuel, and I’ve got some updates for you!

Avoid double type cast when serialising attributes
ActiveModel::Attribute#value already casts model attributes when persisting models, however some model attribute types try to cast a given value before serialising it. This means casting is done twice in most cases. This PR fixes that, giving us some performance boost.

Add ability to set the tags_format for QueryLogs
ActiveRecord::QueryLogs gets a new tags_format option. This makes it possible to specify if we want to use the default :legacy formatter or :sqlcommenter.

Facilitate use of any regular ERB in database.yml
DummyCompiler has been replaced with ERB::Compiler. True to what d…

Shopify Engineering - Shopify Engineering 

A Software Engineer’s Guide to Giving Feedback that Actually Matters

If you see something wrong in a codebase or architecture, and you don’t say something, you will suffer the consequences. Jack teaches how to give feedback that matters to get positive results.

More

Stanko's blog 

“Having a monolith is a single point of failure”

I recently took part in a discussion that brought to light the most unusual argument against having a monolith that I have ever heard - that a monolith is a single point of failure. I want to make clear that I consider monoliths and microservices neither good nor bad, or universally better or ...
Remote Ruby 

Rails Hackathon 2022 & Turbo 7.2 release

[00:01:01] Andrew explains how he had to make a complex data table.


[00:03:27] Chris talks about an entry at Rails Hackathon called “Con[text]” for learning Spanish and English.


[00:05:07] We learn about some of the cool improvements with the new Turbo release.


[00:11:08] Chris tells us everything that went on at Rails Hackathon, and he tells us the winner of the Judges’ Favorite which was Typefighters by Team Rubades.


[00:13:42] Find out more about the Best Solo/Community Favorite award given to Jim Jones’ Checkpoint Rails, and Chris brings up a talk Bret Victor did in 2012 called, “Inventing on Principle.”


[00:19:38] We hear more about the killer submission, Airtable clone by…

Hanami Mastery newest episodes! 

#30 ROM - Mapping is everything

Understand data mapping in ROM, on all levels! In this episode we go through examples of simple to complex data mapping with ROM, with real usecases for each one.
Awesome Ruby Newsletter 

💎 Issue 332 - Richard Schneeman's How to Open Source book is out! 🤩

Ruby Weekly 

Sidekiq 7 (beta) and Sinatra 3 (for real)

#​622 — September 29, 2022

Read on the Web

Ruby Weekly

Phlex: A New Component-Oriented View Framework — Author Joel Drapper has certainly been putting in the effort since creating Phlex a few months ago. It lets you treat everything on a Web page as a distinct component and manage them all as plain old Ruby objects – the view format itself is also entirely pure Ruby which might remind you of _why’s Markaby a little! There’s a ERB to Phlex converter you can play with to see how it looks. GitHub repo.

Joel Drapper

💡 It's early days, so tutorials are thin on the ground, but phlex-sinatra shows off how to use Phlex…

Saeloun Blog 

Meet the most awaited CSS container queries

Rendering websites on different devices has always been a challenge. Before responsive design was introduced, many companies dealt with the problem of changing layout based on screen size, especially mobile, by creating a new website under sub-domain m i.e. m.mywebsite.com. Later responsive design and media queries opened up different layout solutions based on viewport size.

Although media queries solved a lot of layout problems they are not ideal in all cases. Many websites have components that need to change their layout based on the container’s available width. We cannot achieve this solely with media queries. We are forced to write a class or target the element with a selector which…

Ruby Rogues 

Import Maps in Rails 7 with Paweł Dąbrowski - RUBY 565

Import maps is the new feature in Rails 7 that allows us to forego Node.js and tools like Webpack, plus it prevents the need for bundling.  Today on the show, Valentino interviews Paweł Dąbrowski to share his insights about import maps in Rails 7.


In this episode…


  • Mortal Kombat coding 
  • Mastering CSV in Ruby (book)
  • CSV features 
  • What are Import maps in Rails 7 and how do you get started
  • Rails app generator and Rails formation
  • How to handle upgrades
  • New Rails features 

Sponsors


Links


Picks
Honeybadger Developer Blog 

Writing Cleaner JavaScript with Modules

Modules are one of the most commonly used JavaScript features because most JavaScript frameworks and libraries leverage the module feature for organization and componentization. Some developers think that the import and export keywords are ReactJS features.

In this article, I will explain how to encapsulate code using modules to make your projects cleaner. Let's take a look at what encapsulation is in the next section.

Encapsulation

In programming, encapsulation refers to bundling related code in a single source. The code can include associated functions and variables inside files or related files inside a folder.

Encapsulation is used to restrict direct access to data and…

Test Double Blog 

A Better Way to Sort Ruby Objects

tl;dr

  1. We have a new gem called Put
  2. I made a screencast demoing sorting complex objects by multiple conditions, both in pure Ruby and with Put
  3. Here’s the example code
  4. After seeing Put’s README, I was asked to refrain from any “put” wordplay in this post

Not too long; did read

I have a confession to make: I’ve been programming Ruby since 2004 and I still get tripped up whenever I encounter the <=> spaceship operator. As recently as this week, I’ve caught myself slowly and unconfidently working out the rules in my head: “okay, if the receiver is comparably greater than the argument, it should return -1, right?

To avoid this confusion, many Rubyists reach for…

Saeloun Blog 

Rails improves the "in_order_of" querying method

Rails ActiveRecord is continuously being improved. The latest improvement is the “in_order_of” method. This method is used to order records in the order of the given values (of a particular column). This query previously only used to allow symbolic column names, it now handles string values also.

Before

Let’s create a Rocket model which has id and name attributes. Now, when trying to order the records in the order of the given values, we can use the “in_order_of” method as shown below.

  irb(main):012:0> Rocket.in_order_of(:id, [1,2,3]).count
    Rocket Count (1.1ms)  SELECT COUNT(*) FROM "rockets" WHERE "rockets"."id" IN (1, 2, 3)
  => 3

However if we try to use the “in_order_of”…

The Ruby on Rails Podcast 

Episode 437: It's Not Only Sauerkraut and Pickles (Brittany + Nick)

After diving into CrossFit and their favorite comfort foods, Nick and Brittany talk all things conferences: RubyKaigi 2022, Rails SaaS and Rubyconf 2022. Nick ends the episode by sharing some cool Rails upgrade tooling he is working on.

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.

AppSignal

Monitor your apps from A to Z: error tracking,…

Hi, we're Arkency 

Simplify your system debugging by introducing event store linking

Simplify your system debugging by introducing event store linking

Last week I was dealing with an interesting bug. In our system, there was a user that didn’t belong to any tenant. And a tenant that didn’t have any users. It’s a situation that shouldn’t happen in our application.

Debugging that issue was quite simple because of the linking feature of RailsEventStore that we use in our application to correlate all events related to a user in a single stream. By linking to such a user stream you get the possibility to see all events that are related to that certain user account.

What is interesting here is that there’s a UserLeftTenant event, which in our case, should lead to deleting the…

Mike Perham 

Sidekiq 7.0 Beta now Available

Yesterday I released the first public beta of Sidekiq 7.0. This is a major new release with several huge new features, several features removed, APIs refactored and updated requirements. Job Performance Metrics! Embedded mode! Capsules! Strict args! But with all these awesome new features, we refactored a LOT of internal APIs and likely broke a bunch of things. In other words, we really need people to test it and open issues in order to get a smooth 7.
Shopify Engineering - Shopify Engineering 

A Flexible Framework for Effective Pair Programming

Short Ruby Newsletter 

How to start ruby/debug when using Rails with multiple processes

This is a code summary for https://dev.to/ayushn21/remote-debugging-in-rails-7-49nh written by Ayush Newatia

The code for the generated image is here.

Saeloun Blog 

How to enable Rails CSRF Protection?

Cross-site Request Forgery, also known as CSRF, Sea Surf, or XSRF, is a type of cyber attack in which the malicious attacker traps a user into performing certain actions on their behalf. The result of the attack is based on the level of permissions that the user has. Such attacks usually take place when a website happens to completely trust the user once the user proves who they are.

In the world of web application security, CSRF is often said to be the sleeping giant.

How are CSRF attacks done?

Most CSRF attacks exploit the end user’s inability to determine whether the content contains malicious code or not. Most attackers usually hide these elements using social engineering…

BigBinary Blog 

How to detect changes in component visibility when scrolling?

When there is a need to display large set of data, most of the web applicationssplit whole set into several smaller chunks and then serve on demand. Thistechnique is called pagination.

Earlier, pagination looked like this:imageHere, loading next set of data required user to click on next page button.

These days, we use infinite scroll technique which automatically loads next setof data when user scrolls to the bottom of the list. This is more user friendly:image

Several JS libraries are available to facilitate infinite scroll. But to quenchour curiosity about how things work under the hood, it is best to try toimplement it from the scratch.

To implement infinite scroll, we need to know when the user has…

The Bike Shed 

356: The Value of Specialized Vocabulary

Guest and fellow thoughtbotter Stephanie Minn and Joël chat about how the idea of specialized vocabulary came up during a discussion of the Ruby Science book. We have all these names for code smells and refactors. Before knowing these names, we often have a vague sense of the ideas but having a name makes them more real. They also give us ways to talk precisely about what we mean. However, there is a downside since not everyone is familiar with the jargon.


This episode is brought to you by Airbrake. Visit Frictionless error monitoring and performance insight for your app stack.


Transcr…

BigBinary Blog 

Setting up Heroku DNS using cloudflare

Lots of folks know cloudflare for the DDoSprotection, rate liminting etc services it provides. Here at BigBinary we alsouse cloudflare for DNS management.

DNS management is a free service by cloudflare. However on first glance it mightnot appear that it's a free service. Once we add a site then we see a screenlike this. Here we need to remember to scroll down to see the free option.

cloudflare pricing page

Now let's see how we can map the DNS settings from heroku to cloudflare. We willlook at both a standard domain name and then we will take a look at a wildcarddomain name.

Standad domain name

We are hosting GitEmit using Heroku. We are lettingHeroku manage the SSL for this domain.

After setting up domains in Heroku…

Schneems - Programming Practices, Performance, and Pedantry 

My book 'How to Open Source' launches today!

Today is the day. How to Open Source is now available for purchase at howtoopensource.dev.

BootrAils 

Ruby vs JavaScript

JavaScript and Ruby are beautiful ❤

The choice of the programming language will definitely affect what projects you will create and what companies you will be able to work for in the future.

In this article, we decided to compare Ruby and JavaScript, which are good languages to start learning to code. Of course, both have advantages and disadvantages, and it often depends on your goals in programming.

Ruby was invented in 1995 by Yukihiro Matsumoto as he "wanted a genuine object-oriented, easy-to-use scripting language". JavaScript was invented by Brendan Eich and was originally thought to be used only in the browser as an interface language and first appeared also in 1995 in Netscape 2.0…

Short Ruby Newsletter 

👋 Issue #11 - 19-25 September 2022

If you want a short excerpt of this newsletter containing only some of the images with code, I created one here. But I invite you to read the entire newsletter as it has excellent content 😊.

This edition was created with support from @adrianthedev from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and from @jcsrb, who sent me recommendations to include in the newsletter.


👉 Schwad shared how quick it is to prototype ideas with Rails 7:

've been doing some work on a Rails 7 Bootstrap 5 application this month and I am _loving_ life. The loop from idea-to-feature is so short. If I need something fancy I can literally just reach over and grab hotwire. If I need a component I just go to the bootstrap docs. ❤️
Source: @schwad_rb on Twitter

👉 Brad Gessler shared a snippet of code that will help you not leak instance variables in partials in Rails:

Source: @bradgessler on Twitter

You can check a working example on the public project Brad shared on…

👉 Emmanuel Hayford …

Test Double Blog 

Double Agent Profile: Eve Ragins

Name: Eve Ragins
Designation: Agent 00138
Double Agent Role: Senior Software Consultant
Special Skills: Finding gaps. Filling gaps. Distilling complexity. Solving the hard problems.
Aliases: GitHub, LinkedIn
Location: Soon-to-be Nomad
Favorite Emoji: 🤔

What impact are you proudest of in your career?

I’ve built at least a couple core backend systems that — to the best of my knowledge — still serve as the backbones for mission-critical systems today. The two that come to mind are one for the WA Employment Security Department which is like glue for making batch jobs, and the other is some code which let us build modern apps on top of a mainframe. Impactfully, I’m proud of these…

Island94.org 

Persian Tahchin-inspired crispy chicken rice

Tahchin

This is a Milk Street recipe, but because I detest their instructional design, I redesigned it here. I like this dish because:

  • It can be made with ingredients from Trader Joe’s.
  • It has currants.
  • Crispy, buttery starch is great.
  • It’s resilient; the second time I made it with indirect heat on a propane bbq grill because my oven was on the fritz. Still great. Also I’ve tried brown basmati rice, tried doubling the eggs, tripled the garlic, I’m not measuring the butter and currents. Still great.

Ingredients

  • 1.5 cups basmati rice
  • 1/4 teaspoon saffron threads
  • 2 tablespoons boiling water
  • 12 ounces boneless skinless chicken thighs. I think this would also work with seitan or…
Honeybadger Developer Blog 

Working with Markdown in PHP

Markdown is a markup language that is quite useful for web developers. It can be used for writing technical documentation, blogs, books, and even writing comments on websites, such as GitHub.

In this article, we’ll take a look at what Markdown is, the benefits of using it, and how to convert Markdown to HTML using PHP. We'll also cover how you can create your own CommonMark PHP extensions to add new features and syntax to your Markdown files.

What is Markdown?

Before we touch any code, let's first take a look at what Markdown is, its history, and a few different examples of how you can use it.

Markdown is a markup language that you can use to create formatted text, such as HTML. For…

AkitaOnRails.com 

[Akitando] #128 - Entendendo Pacotes com Slackware | Deb, Apt, Tarbals

Como gerenciadores de pacotes como APT funcionam? O que tem num pacote? Vamos instalar um Slackware, uma das distros de Linux mais antigas, e ver como evoluímos de gerenciar tarballs pra gerenciar resolução de dependências com pacotes modernos como formato DEB.

Hoje você vai começar a entender como software num Linux é organizado de verdade.

== Conteúdo

  • 00:00 - Intro
  • 01:21 - CAP 1 - Como nós, reviewers, trapaceamos
  • 04:15 - CAP 2 - Instalação como nos Anos 90: Slackware
  • 06:24 - CAP 3 - Particionando o Drive: CFDISK
  • 10:32 - CAP 4 - Filesystems e Mount Points
  • 16:36 - CAP 5 - Como APT instala pacotes? Formato DEB
  • 25:14 - CAP 6 - Formato de Pacotes Original: pacotes no Slackware
  • 31:57 -…

== Links

  • Build & Install Slackware Packages Automatically (https://medium.com/netdef/build-install-slackware-packages-automatically-b2986d2f86f9)
  • SlackBuilds.org…

SCRIPT

Olá pessoal, Fabio Akita

Vamos continuar a minissérie de Linux…

The RubyMine Blog : Intelligent Ruby and Rails IDE | The JetBrains Blog 

RubyMine 2022.3 EAP Is Open!

Hello everyone,

Welcome to the third Early Access Program of 2022! As always, we encourage you to try the new features before the official release, and we’re looking forward to your feedback.

In this build, we smartened up our existing Rails features and supported some new ones. Let us know what you think in the comments or by selecting Main menu | Help | Submit feedback in your IDE.

Here are the highlights of the first 2022.3 EAP build:

A new inlay hint for controller actions

We’ve added inlay hints above each controller action with a URL that links to the action.

Clicking an inlay hint opens the list of available actions for the URL:

  • Go to declaration or usages: navigates you to the…
Ruby on Rails 

Improved assert_redirected_to, improved error messages and more!

Hi, this is Greg, bringing you the latest changes in the Rails framework.

Allow specifying the HTTP status code in assert_redirected_to Before this change, assert_redirect_to asserted any 3XX response, but with this change, it is possible to assert a specific response code, like 301.

Allow passing classes to dom_id Allowing dom_id to receive a Ruby class, instead of an instance of a class, makes it behave like dom_class, and besides saving a few keystrokes, it saves memory too, because Ruby doesn’t need to instantiate an entire object with all its callbacks and such.

Improve error messages on bin/setup Changing bin/setup to use system(…, exception: true) gives more information when a…

Allow to pass –force to…

Remote Ruby 

You Gotta Risk It For The Brisket

[00:00:15] What is this cursed idea thing Andrew did with Storybook?


[00:05:31] Andrew mentioned using MDX format and he tells us what it is, Chris brings up the PHP days and components, and Andrew talks about architecture. 


[00:10:51] Being a visual person, Andrew explains another thing he really likes about Storybook.


[00:17:29] Jason talks about finding his Zen using Tailwind in a project.  


[00:20:25] Chis wonders if Jason runs into issues with having to undo some of the stuff, and Jason explains how he’s been using more CSS and a problem he ran into.  


[00:24:02] CSS Variables are discussed and why they’re awesome, and Andrew tells us about the fallback for CSS Variables.  


[00:24:3…

DEV Community 👩‍💻👨‍💻: Doctolib Engineering 

Could not create unique index: how to solve duplication errors

Unique indexes enforce the uniqueness (as their name implies) of one or more columns' values. They can guarantee one-to-one relationships in your model. For instance, let's have a unique shopping cart per user:

=# create unique index uidx_shopping_carts_on_user_id on shopping_carts (user_id);

ERROR:  could not create unique index "uidx_shopping_carts_by_user_id"
DETAIL:  Key (user_id)=(2) is duplicated.

Wow! What was that? It seems that the index can not be created: some existing rows already infringe the constraint.

Oopsy

Let's explore the data a bit. Can we spot culprits?

=# select user_id from shopping_carts order by user_id;

 user_id 
---------
       1
       2

Oopsy, "2" appears…

Ruby Rogues 

Remote Working Culture with Jake Yesbeck - RUBY 564

Post pandemic, remote work is here to stay.  Today on the show, the panel and Jake Yesbeck share their insights about remote work for developers and the latest developments for the 2022 workforce and beyond. 

In this episode…


  • The transition to remote
  • Being intentional about career growth
  • Book clubs
  • Separating work from life
  • Changes post pandemic
  • Connecting in public channels
  • How do you measure productivity?
  • Interviews / interviewing remotely

Sponsors


Links


Picks

Awesome Ruby Newsletter 

💎 Issue 331 - Short Ruby Newsletter Issue #10

Planet Argon Blog 

Full-Stack Development Using React: Developers’ Quarterly Study

Full-Stack Development Using React: Developers’ Quarterly Study

Learn about the interesting full-stack development projects our team worked on during this quarter.

Continue Reading

Shopify Engineering - Shopify Engineering 

Lessons From Building Android Widgets

Stanko's blog 

The humble ActiveModel

ActiveModel is one of my most used tools in Rails applications. I use it in service objects, form objects and objects that represent external entities. Why? Because it provides a nice interface for validating inputs and results, it can have callbacks for pre and post-processing data, and it in...
Shopify Engineering - Shopify Engineering 

Lessons From Building iOS Widgets

Ruby Weekly 

A late April 1st proposal for Ruby?

#​621 — September 22, 2022

Read on the Web

Ruby Weekly

Proposal: Extending HereDocs to Support Multiple Languages? — To set the scene here, Matz’s initial reaction to this proposal was “There’s still half a year left until April Fool’s Day.” The idea here is to be able to specify a format/language against heredocs (somewhat as with Markdown code blocks) and to then process those documents dynamically in a custom method. Joke or not, when such an esteemed core team member has an idea, it’s worth checking out, and plenty of jokes have taken off (SOAP.. LINQ.. 😏)

Koichi 'ko1' Sasada

Debug Ruby Apps in…

Saeloun Blog 

When to use the two hooks - useCallback and useMemo?

Every state change in React can cause re-rendering which can affect badly on application. Mostly when the component size gets increased. useCallback and useMemo hooks are used for improvising the performance of React application.

Does useCallback and useMemo do the same thing?

Though both are used for performance optimization, it might be confusing for developers regarding their use-case. So let’s understand them thoroughly.

Before diving deeply into their difference, let’s understand why they are used.

  • As mentioned above, both hooks are used for performance optimization.
  • If our application is doing frequent re-rendering then based on the use-case we can use one of them.

Let’s…

Short Ruby Newsletter 

How to use Postgres Enums with Rails 7

This is a code summary for https://allaboutcoding.ghinda.com/how-to-work-with-postgresql-enums-in-rails-7

If you want to play with the code, I create a single file Rails app here: postgres_enums_in_rails_7.rb


If you like this kind of content you should consider subscribing to my weekly newsletter with fresh content about Ruby and Rails.

RubySec 

CVE-2022-39224 (arr-pm): arr-pm vulnerable to arbitrary shell execution when extracting or listing files contained in a malicious rpm

### Impact Arbitrary shell execution is possible when using RPM::File#files and RPM::File#extract if the RPM contains a malicious "payload compressor" field. This vulnerability impacts the `extract` and `files` methods of the `RPM::File` class in the affected versions of this library. ### Patches Version 0.0.12 is available with a fix for these issues. ### Workarounds When using an affected version of this library (arr-pm), ensure any RPMs being processed contain valid/known payload compressor values. Such values include: gzip, bzip2, xz, zstd, and lzma. You can check the payload compressor field in an rpm by using the rpm command line tool. For example: ``` % rpm -qp…
RubySec 

GHSA-4qw4-jpp4-8gvp (commonmarker): Unbounded resource exhaustion in cmark-gfm autolink extension may lead to denial of service

### Impact CommonMarker uses `cmark-gfm` for rendering [Github Flavored Markdown](https://github.github.com/gfm/). A polynomial time complexity issue in cmark-gfm's autolink extension may lead to unbounded resource exhaustion and subsequent denial of service. ### Patches This vulnerability has been patched in the following CommonMarker release: - v0.23.6 ### Workarounds Disable use of the autolink extension. ### References https://en.wikipedia.org/wiki/Time_complexity
Honeybadger Developer Blog 

Building a Realtime Chat App with Django Channels and WebSockets

Django is well known for being used to develop servers for HTTP connections and requests for applications. Unfortunately, when building applications that require the connection to remain open for a two-way connection, such as conferencing and chatting applications, using an HTTP connection is inefficient. This is where WebSockets come into play.

WebSockets provide a means of opening a two-way connection between the client and the server so that all users connected to the open network can get related data in real time. It is a stateful protocol, which means connection authentication is only required once; the client credential is stored, and there is no further need for authentication until…

Hanami Mastery newest episodes! 

#29 Leverage ROM Repositories

Relations are the heart of ROM, but for bigger applications, you'll appreciate to know repositories.
Hanami 

Announcing Hanami v2.0.0.beta3

Hello again, friends! We’re excited to share our release of Hanami 2.0.0.beta3!

Code Reloading

Hanami server and console now support code reloading.

New apps are generated with hanami-reloader in Gemfile and with a new Guardfile. Code reloading for hanami server is based on guard. When the file system changes because of code edits, Guard restarts the Hanami server.

In Hanami 1, we achieved code reloading with an "inside-the-framework" approach that turned to be problematic. With hanami-reloader, we implemented this "outside-the-framework" that has positive implications:

  • File system watching is delegated to Guard
  • Hanami is now free from code reloading…
Saeloun Blog 

How to set up a CI/CD workflow for Expo React Native application using Github Actions.

CI/CD is one of the most important practices of XP. Having set this up since the beginning can help in identify and fix issues earlier and faster time to market. Here at Saeloun, we make sure it gets set up since the start of the project.

Let us start setting up a CI/CD for Expo react-native application. First, we will set up the CI process so it gets run on each of the branches we create and then we will set up the CD process specific to the develop or main branch because we need to create builds for the latest changes that get merged to develop or main.

Continuous Integration

  • As we are using Github Actions, we need to create a ci.yml file inside the .github/workflows
The Ruby on Rails Podcast 

Episode 436: The RoR Podcast x Rubber Duck Dev Show: Engineering Manager vs. Product Manager

Brittany returns to the the Rubber Duck Dev Show! In this episode, Chris and Creston discuss the different viewpoints and objectives for engineering managers vs. product managers with Brittany Martin & Josh Gaastra.

Show Notes & Links:

Sponsored By:

Scout APM

Try their error monitoring and APM free for 14-days, no credit card needed! And as an added bonus for Ruby on Rails listeners: Scout will donate $5 to the open-source project of your choice when you deploy. Learn more at http://scoutapm.com/rubyonrails.

Mirror Placement

Mirror Placement are the Ruby on Rails & JavaScript recruiters. They are actively engaged with a wide…

Ruby Magic by AppSignal 

Debugging in Ruby with AppSignal

An application monitoring tool (APM) is not just useful for seeing how your application performs through graphs and visuals. We can go deeper and use an APM to understand how your application behaves in a certain environment.

As developers, we should aim to be less reactive to errors and more predictive, avoiding crashes for end-users.

One way to accomplish this is by using monitoring tools to debug our application when an error occurs. AppSignal has advanced features that allow us to intelligently debug our logs and thus reflect this precautionary thinking in our applications.

This article will show you how to better log and debug your Ruby application using AppSignal.

Integrate Your Ruby…

Martian Chronicles, Evil Martians’ team blog 

WebSocket Director: scenario-based integration tests for realtime apps

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

This post introduces WebSocket Director (wsdirector), a testing automation tool for WebSocket servers which uses human-readable scenarios stored in YAML or JSON files.

Black-box testing, end-to-end testing, or system testing, according to Ruby on Rails, is just the tip of the testing iceberg (or diamond, as you wish). Still, it plays a significant role achieving software stability. However, writing and maintaining high-level integration tests is not a piece of cake, especially when you go beyond…

BigBinary Blog 

How we upgraded from Rails 6 to Rails 7

Recently, we upgraded all neeto products to Rails 7usingRails upgrade guide.

Here are the issues we faced during the upgrade.

Migrating to Active Record Encryption

This was the biggest challenge we faced during the upgrade. For encryptingcolumns, we had used theattr_encrypted gem. HoweverRails 7 came withActive Record Encryption.So we needed to decrypt the records in the production database and encrypt themusing Active Record Encryption. We found that "attr_encrypted" gem wasincompatible with Rails 7. So the only option was to remove the "attr_encrypted"gem and decrypt the records using a script. We used the following method todecrypt the records.

def decrypted_attribute(attribute_name, record)…
Code with Jason 

162 - Large Rails Apps with Alex Evanczuk, Software Engineer at Gusto

In this episode, I'm joined by Alex Evanczuk for a conversation about large Rails applications, how they grow, and how to keep things under control as they grow.

Saeloun Blog 

Rails now uses error_highlight to locate the columns where an error is present

Ruby 3.1 introduced a new feature called error_highlight which allows you to pinpoint the exact column where an error is present.

Standard error messages in Rails show the row the error has occurred in. This is useful in most scenarios, however, for certain types of errors it can get less helpful.

For example, consider a hash of hashes. If accessing a key that does not exist, it can often be difficult to pinpoint the location where the key was accessed incorrectly.

Consider the below example,

  hash = { jane: { name: "Jane", age: "25", city: "NYC" }}
  hash[:john][:age]

The above code will raise an error like,

  NoMethodError: undefined method `[]` for nil:NilClass

However, it…

The Rails Tech Debt Blog 

Securely using SSH keys in Docker to access private Github repositories

If you search online for using SSH keys with Docker, to access private Github repositories, you will get a lot of search results, but the solutions you’ll find are almost all out of date, insecure, or fragmentary (i.e. they provide a small snippet of information but not a complete solution). Given how popular both Docker and Github are, I found this quite surprising. We recently had to set up Docker with a Rails application that fetches gems from private repositories. We’re also using Docker Compose, which added to the challenge. This comment on the Docker project, which is from February 2021, unfortunately is still accurate:

There are several questions and answers out there about how…

Short Ruby Newsletter 

Ways to call a method in Ruby

This is a code summary for https://www.notonlycode.org/12-ways-to-call-a-method-in-ruby/

The source code if you want to play with this is here.


If you like this kind of content you should consider subscribing to my weekly newsletter with fresh content about Ruby and Rails.

Hanami Mastery newest episodes! 

#28 Configure ROM from scratch

Hanami 2.0 comes without the persistence layer nor views preconfigured. It is useful then to know how to set up the best ORM available in the Ruby ecosystem.
The Bike Shed 

355: Test Performance

Guest Geoff Harcourt, CTO of CommonLit, joins Joël to talk about a thing that comes up with a lot with clients: the performance of their test suite. It's often a concern because with test suites, until it becomes a problem, people tend to not treat it very well, and people ask for help on making their test suites faster. Geoff shares how he handles a scenario like this at CommonLit.


This episode is brought to you by Airbrake. Visit Frictionless error monitoring and performance insight for your app stack.


Transcript:

JOËL: Hello and welcome to another episode of The Bike Shed, a weekly podcast from your…

Island94.org 

Weeknotes: September 19, 2022

  • My mom, Susan, Sue, passed away at her home last Tuesday morning. Her wishes were that people recognize her life through donations to the Santa Barbara Food Bank and Save the Children. My brother and I are figuring out everything else; email me at bensheldon@gmail.com if you’d like to stay updated.
  • Having spent the last 5 weeks with my mom, her doctors’ ongoing prognoses that she “has days” was incorrect for quite a while until it wasn’t. We got to the zoo and the Botanic Gardens together. I enjoyed flustering the hospice nurse over the phone by passing along their questions directly, like “hey mom, how are your bowels?” and the nurse’s response of “oh, oh, I didn’t realize she was…
Test Double Blog 

Reflecting on what it means to go back home

As some of you may already know, I was born in Ukraine, in a city called Kharkiv. My mother made the difficult decision to leave the country in pursuit of a better life for the two of us in America, and at 5 years old, I became an immigrant on the other side of the world.

Painting of a woman in traditional Ukrainian dress embracing her daughter while standing in a field of grain. A painting by my mother, Yelena Liberman, "Ukraine - Today, Tomorrow, and Always!"

When Russia invaded Ukraine, I was flooded with memories, revealing Ukraine’s significance in my life. Every trip I’d ever taken, every family member I’d met, studying the Russian language year after year. Every moment I’d ever spent with my family, sitting across from my cousins, bringing them gifts from America, big suitcases…

Benito Serna 

Broadcast multiple actions with broadcast_render

Imagine that you are creating a record (let’s say a tweet), and on creation, you want to add the tweet to the page and also update the tweets count in the page…

But you want to update the content, not just for the current user, but for all the users in the page, you want to broadcast the changes.

How would you do it?

Well, here I want to show you how you can use broadcast_render or its _later variations, to do it.

Example video

You will be able to do something like this:

Use broadcast_render_later_to

This method will help you render a turbo stream template with the current model as the local variable, so you can send something like this:

<%= turbo_stream.replace "new_tweet" do %>
Ruby Together News 

August 2022 Monthly Update

Hello! Welcome to the monthly update. During August, our work was supported by Zendesk and many others.

ruby together news

In August, Ruby Together was supported by 33 different companies, including Ruby member Zendesk. In total, we were supported by 123 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.20, 3.3.21) and Bundler (2.3.20, 2.3.21).

The following are the main improvements shipped during this month (see the changelog for more improvements and fixes):

  • added full support for musl variants for gems, both in RubyGems and Bundler - #4488, #5852.
  • imple…
Passenger - Phusion Blog 

Passenger 6.0.15

Passenger 6.0.15

Version 6.0.15 of the Passenger application server has been released. This release adds Enterprise Linux 9 (RHEL, Rocky, Alma) packages, and improves Solaris support.

Passenger 6 introduced Generic Language Support, or: the ability to support any and all arbitrary apps.

Updates & improvements

  • Restore ability to build against upstream libev. Contributed by Antonio Terceiro. Closes GH-1544.
  • Improve rvm gemset detection. Closes GH-2420.
  • Fix watchdog error on disable-log-prefix flag. Contributed by Paul Hanyzewski. Closes GH-2363.
  • Upgrades Boost to 1.80.
  • Fixed compilation on some platforms by explicitely using the stl queue. Closes GH-2440.
  • Raise an error in case rack gets an ENOBUFS error.…
DEV Community 👩‍💻👨‍💻: Truemark Technology 

[Solved] Error while Installing mysql2 Gem in M1 Mac

In Ruby on Rails applications with mysql2 gem, mysql2 gem always threw error when trying in the new M1 Mac. The error always said "ld: library not found for -lzstd" and "make failed".

Let's resolve this issue today!

Assumptions

  1. You are using rbenv for ruby
  2. You are using homebrew

Error Message

Whenever I did bundle install inside the project, I got the following error:

linking shared-object mysql2/mysql2.bundle
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Solution

To resolve the issue, you will have to provide the…

BootrAils 

Ruby group_by or Rails group_by

What is the group_by method in Ruby?

The .group_by method is included in Ruby's Enumerable module. We have already written about the Enumerable module and Enumerators in previous blog entries. This is because of the importance of these concepts, as they are key to interacting with data: iterating through collections of elements, searching, fetching and sorting, among other features.

group_by: The definition

As per Ruby's Documentation, the group_by method sorts a collection of data according to a condition passed as a block.

group_by{|element|...} -> hash

Here, being the block: {|element|...}.

Important aspects

  • When using group_by with a block, the result is a hash. The hash is built of…
Short Ruby Newsletter 

🔖 Issue #10 - 12-18 September 2022

Hello,

I’m @lucianghinda, the curator of this newsletter. If you want a short excerpt of this newsletter containing only some of the images with code, I created one here. But I invite you to read the entire newsletter as it has excellent content 😊.

If you like it and want to help me reach a wider audience, I would kindly ask you to leave some feedback/short written testimonial that I can display on the About page.

Leave a short testimonial

This edition was created with support from @adrianthedev from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and from @jcsrb, who sent me recommendations to include in the newsletter.

If you have any feedback or ideas about this…

Honeybadger Developer Blog 

Deploying Rails with Docker and AWS Fargate

In this tutorial, you'll learn how to deploy a dockerized Ruby on Rails 7 app on Amazon's Elastic Cloud using Fargate. We will learn what Fargate is and how it makes the deployment of containerized applications relatively seamless.

After completing this tutorial, you'll know how to perform the following:

  • Dockerize a simple Rails application.
  • Push your code to Amazon's Elastic Container Repository (ECR).
  • Setup a PostgreSQL database using Amazon's RDS service.
  • Configure an Elastic Container cluster.
  • Deploy your Rails app to production using Fargate.

Prerequisites

  • An AWS account. If you don't have one, sign up here.
  • AWS CLI, Docker, and Docker Compose installed on your development…

Dockerizing a Simple Rails App

We'll start by…

Andy Croll 

Use before? and after? Methods When Comparing Dates and Times in Rails

Active Support contains many additions to the basic classes that form the standard libraries of Ruby. There are extensions to String, Hash, Array and even Date and Time.

If you spend most of your time working inside Rails applications, you might not realise that these are Rails-isms rather than Ruby-isms.

Some folks dislike these ”superfluous” additions. Some of these additions end up back inside the Ruby standard library itself. Some of these methods help me not make mistakes when comparing times and dates.

Instead of…

…comparing dates and times with greater than or less than operators:

Date.new(1979, 9, 12) > Time.zone.now
#=> false

10.minutes_ago < 5.minutes.from_now
#=> true

Use…

Test Double Blog 

React and React Native workshops — Fall 2022

I’m offering workshops on a variety of React and React Native topics this fall. Most of them are available virtually, so you can join from anywhere with an internet connection. (I bet you have one of those if you’re reading this!) They’re offered as part of larger conferences with lots of great speakers and additional workshops included in the ticket price, too.

Here are the topics I’ll lead workshops on:

Designing Effective Tests with React Testing Library

React Testing Library is a…

DEV Community 👩‍💻👨‍💻: Brandon Weaver 

Beyond Senior – The Peacock, the Hermit, and the Counsel

After a number of conversations over the past few years with several other engineers who have moved beyond senior levels into staff and principal positions I've come away with a lot of insights, many of which have seen their way to Twitter or other conversations first, but now it's time to start collecting some of those stories into this new series: Beyond Senior.

What does it mean to go beyond the senior level in an engineering organization?

That's the question we're going to be looking at throughout this series.

The Peacock, the Hermit, and the Counsel

The more senior you become in your role the you need to self-market and sell people on your ideas. In order to drive…

Ruby on Rails 

Handling reconnects in Action Cable, no more Coffeescript and a new guide.

Hi, this is Petrik with this week’s Rails updates and some Hotwire news.

Add exclude? method to ActionController::Parameters

exclude? returns true if the given key is not present in the parameters. It is the inverse of include?. Adding this method keeps things a little more consistent with a Hash.

params = ActionController::Parameters.new(id: 1)
params.exclude?(:name) # => true
params.exclude?(:id) # => false

Add ability to handle reconnects with the connected callback

If a subscriber misses some messages when the connection is lost, this allows them to handle reconnects with the connected() callback.

consumer.subscriptions.create("ExampleChannel", {
  connected({reconnected}) {
   …
RubyGems Blog 

August 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 August.

RubyGems News

This month in RubyGems, we released new versions of RubyGems (3.3.20, 3.3.21) and Bundler(2.3.20, 2.3.21).

The following are the main improvements shipped during this month (see the changelog for more improvements and fixes):

  • added full support in RubyGems and Bundler for musl variants - #4488, #5852.
  • implemented Bundler.settings[:only] to install gems of the only specified groups (a longstanding feature request we finally decided to add) - #…
  • restored…
Remote Ruby 

Phlexing with Joel Drapper

[00:03:50] Joel tells us about himself, what led him to creating Phlex, and what problem he was trying to solve with it.


[00:08:13] We find out the testing story and how the reception has been with Phlex.


[00:13:45] Andrew brings up how Joel has been doing a lot of performance stuff with Phlex and Joel explains how he’s making the benchmarks and how he’s figuring out all these performance things.


[00:16:53] Joel shares some interesting things he’s tried that were easy and one that had the biggest impact. 


[00:22:04] Joel tells us a good example of something that’s not a smart thing to do in application code, but they’ve decided to do in Phlex.


[00:23:33] Find out what Joel is focused on…

Martian Chronicles, Evil Martians’ team blog 

The journey from CircleCI to GitHub Actions

Authors: Ilya Cherepanov, Site Reliability Engineer, and Travis Turner, Tech EditorTopics: Backend, Site Reliability Engineering, Continuous Integration, Docker, Ruby on Rails, Node.js

Take Ruby on Rails and Node.js projects from CircleCI to GitHub Actions with almost no changes, learn the differences between the two, and more!

So, you're a longtime user of CircleCI with projects set up and running like clockwork. But, one fine morning, it strikes you to switch to GitHub Actions. Why? Maybe you'd like to use fewer third party services and want to keep your code and CI process in one place? Perhaps you already have a paid GitHub account with free GitHub Actions minutes just lying around? One…

The Rails Tech Debt Blog 

What Does load_defaults Do?

Let’s begin with a simple question:

Have you seen config.load_defaults 6 in any application?

6 is an argument and could vary, I’m just giving an example.

While upgrading a Rails application from 5.1 to 6.0 we had an “easy” question.

Should We Run the rails app:update Command?

The quick answer is: yes, we should, why not?!

After running the rails app:update command, there are many file changes that the command did for us.

It was time to run the test suite, and guess what? Everything failed. The next step forward was to undo all the changes and start with a single configuration change we thought would be easy and safe. Then we added the config.load_defaults 6.0 line and ran the…

Awesome Ruby Newsletter 

💎 Issue 330 - Why I don’t enjoy RSpec all that much

Ruby Weekly 

Ruby's parser is to be rewritten

#​620 — September 15, 2022

Read on the Web

Ruby Weekly

Ruby 3.2.0 Preview 2 Released — The countdown to Christmas Day, and therefore a key new version of Ruby, continues. Preview releases in recent years have been quite reliable (it’s not the 1.9 days anymore!) so if you want to play with the new WASI-based WebAssembly support, regular expression timeouts, rest param changes, or YJIT’s support for arm64/aarch64.. now is as good a time as any.

Yui Naruse

Send Email Directly from Your Ruby App with Courier — Using a marketing tool to email your users? With the Courier gem you can notify your users with a…

Shopify Engineering - Shopify Engineering 

What is a Full Stack Data Scientist?

Blog 

Old Ruby Codebase - When to Update, What to Consider (Checklist)

A programming saying to live by is “code that you don’t touch gets rusty over time”. We have to realize that our piece of software is not a completely isolated, independent unit (even when using containerization like Docker) but something that lives in a continuously evolving ecosystem. The platform where we start running the first version of our system is probably not the same one that runs it today. Or tomorrow.

Ruby Rogues 

Ruby on Kubernetes Without the Headaches Using Kuby - RUBY 563

For years, the Rails community has been clamoring for Active Deployment, a magical out-of-the-box mechanism for deploying applications.  Today on the show, Cameron Dutro shares how you can deploy Rails apps on Kubernetes with Kuby.  De-stress your deployments today with these simple strategies.


In this episode…


  • Active deployments for Rails apps
  • Docker containers and Kubernetes 
  • Controlling your environment
  • Flexible without vendor lock in
  • Building images with Kuby
  • Plug in providers
  • Why Kubernetes for your apps
  • Multinode set ups with Kuby
  • Deploying Kuby 

Sponsors


Links

RubySec 

CVE-2022-25765 (pdfkit): PDFKit vulnerable to Command Injection

The package pdfkit from version 0.0.0 through version 0.8.6 is vulnerable to Command Injection where the URL is not properly sanitized.
RubySec 

GHSA-qcqv-38jg-2r43 (pageflow): Pageflow vulnerable to insecure direct object reference in membership update endpoint

### Impact Pageflow has a membership edit feature which allows users to edit the roles of user memberships associated with an account that they have the `manager` role to (including their own). While the `Entity` dropdown select field is greyed out in the UI, an attacker can use tools which allow sending arbitrary HTTP request to craft a request to the `/admin/users/{user_id}/memberships/{membership_id}` endpoint containing an additional `membership[entity_id]` parameter. This parameter is honored when the membership is updated, allowing an attacker to update the membership object associated with their own account (with `manager` role) to be associated with a different attacker-chosen…
RubySec 

GHSA-wrrw-crp8-979q (pageflow): Pageflow vulnerable to sensitive user data extraction via Ransack query injection

### Impact The attack allows extracting sensitive properties of database objects that are associated with users or entries belonging to an account that the attacker has access to. Pageflow uses the `ActiveAdmin` Ruby library to provide some management features to its users. `ActiveAdmin` relies on the `Ransack` library to implement search functionality. In its default configuration, `Ransack` will allow for query conditions based on properties of associated database objects [1]. The `*_starts_with`, `*_ends_with` or `*_contains` search matchers [2] can then be abused to exfiltrate sensitive string values of associated database objects via character-by-character brute-force. [1]…
Honeybadger Developer Blog 

Multithreading in JavaScript with Web Workers

There are many problems associated with JavaScript’s single-threaded behavior. Among them is combining long-running tasks with the UI components simultaneously. The highlighted issue can cause a huge loophole in our web app when a CPU-intensive task blocks the UI components, making the webpage freeze.

Often, developers use the setTimeout function and event-driven architectures to mimic concurrency. Even the setTimeout() function isn't part of JavaScript features; it belongs to the environments in which the JavaScript VM is embedded, such as Node.js or browsers. They provide setTimeout() via environment-specific APIs. This way, we are only changing a synchronous behavior to an asynchronous

Shopify Engineering - Shopify Engineering 

Managing React Form State Using the React-Form Library

Saeloun Blog 

Rails 7 adds default value support for binary columns for SQLite

While ActiveRecord is a behemoth encompassing a large feature-set, some WTFs pop up every now and then. One such WTF is the lack of support for default values for binary columns in SQLite.

Before

Let’s create a string column in a model that uses a SQLite database and add a default value to it.

# db/migrate/20220821142603_add_string_to_physician.rb
# class AddStringToPhysician < ActiveRecord::Migration[7.0]
#   def change
#     add_column :physicians, :signature, :string, default: "Regards"
#   end
# end

irb(main):001:0> physician = Physician.create! name: "Belle"
                 ...
irb(main):002:0> physician.signature
=> "Regards"
irb(main):003:0> physician.reload.signature
=> "Regard…

Let’s do the same with a binary column.

# db/migrate/20220821142330_add_greeting_to_physician.rb
# class AddGreetingToPhysician < ActiveRecord::Migration[7.0]
#   def change
#     add_column :physicians, :greeting, :binary, default: "Hello!"
#   end
# end

irb(main):001:0> physician = Physician.create! name: "Belle"
   (0.6ms)  SELECT sqlite_version(*
The Ruby on Rails Podcast 

Episode 435: My Boss is Here with Joel Schlundt

Joel Schlundt is the CTO of TextUs and Brittany's boss. After diving into two origin stories, the pair discuss the Senior Backend Engineer role they are hiring for, applications they never want to build again and the importance of off-sites for remote teams. They cap the conversation off with a horror story.

Announcements

The Ruby on Rails Podcast Store

Fun original designs like “Tell Me Your Developer Origin Story”, “Ruby is Badass”, “Ruby on Tails” and “the Established in Rails” series in shirts, hoodies, magnets, stickers and bandanas. Net proceeds of store purchases benefit Steptember, to raise funds for research and innovation for cerebral palsy.

From Wednesday, September…

Josh Software 

Google Cloud Pub/Sub messages using Go package : pubsub

Package pubsub provides an easy way to publish and receive Google Cloud Pub/Sub messages, hiding the details of the underlying server RPCs (Remote Procedure Calls). Google Cloud Pub/Sub is a many-to-many, asynchronous messaging system that decouples senders and receivers. Publishing Google Cloud Pub/Sub messages are published to topics. Topics may be created using the pubsub package like: Next, we … Continue reading Google Cloud Pub/Sub messages using Go package : pubsub
Short Ruby Newsletter 

How constant lookup works in Ruby

This is a code summary for https://cirw.in/blog/constant-lookup

Code samples run on Ruby 3.1.2

Find all the code I used to generate images here.

You should also read the full article I summarised here as I did not include all examples from the article, but only the most important ones.


Further reading:

I also found a gist that explains some of how constant lookup works in Ruby with code: Constant Lookup in Ruby

And also, this discussion in the Ruby lang issue tracker is important if you want to understand how all works deep down: https://bugs.ruby-lang.org/issues/18622


If you like this kind of content you should consider subscribing to my weekly newsletter with fresh content about Ruby and Rails.

JRuby.org News 

JRuby 9.3.8.0 Released

The JRuby community is pleased to announce the release of JRuby 9.3.8.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, @ccutrer, @evaniainbrooks, @naveensrinivasan

Ruby Compatibility

  • Altering the visibility of an included module method no longer changes what super method gets called. (#7240, #7343, #7344, #7356)
  • Thread termination at shutdown is more robust and visits all…

Standard Library

  • csv has been updated to 3.2.5 to pick up a fix that eliminates fiber use for simple…
Code with Jason 

161 - Adrian Marin, Founder of Avo Admin

In this episode, I talk with Adrian Marin about Avo Admin and how it compares to Jumpstart and Bullet Train, the origins of Avo Admin, the early struggles of developing Avo Admin, making the leap to working on Avo full time, the size of the Rails community,  achieving profitability and the price of ramen.

Saeloun Blog 

Rails 7 updates through_reflection to distribute transactions across database connections

While ActiveRecord works pretty great across most scenarios, it struggles with multi-database architectures. Fortunately, the past few releases have had a lot of work done in this aspect.

One major drawback is the way transactions work in a multi-database architecture. A transaction is basically a set of database operations that are performed as a single unit. Here’s an example,

irb(main):001:1* ActiveRecord::Base.transaction do
irb(main):002:1*   Company.first.touch
irb(main):003:1*   Company.last.touch
irb(main):004:0> end
  TRANSACTION (0.1ms)  begin transaction
  Company Load (0.2ms)  SELECT "companies".* FROM "companies" ORDER BY "companies"."id" ASC LIMIT ?  [["LIMIT", 1]]
  Company
Short Ruby Newsletter 

Ruby Value Objects

This is a #codesummary for https://thoughtbot.com/blog/value-object-semantics-in-ruby


If you like this kind of content you should consider subscribing to my weekly newsletter with fresh content about Ruby and Rails.

The Bike Shed 

354: The History of Computing

Why does the history of computing matter? Joël and Developer at thoughtbot Sara Jackson, ponder this and share some cool stories (and trivia!!) behind the tools we use in the industry.


This episode is brought to you by Airbrake. Visit Frictionless error monitoring and performance insight for your app stack.


Test Double Blog 

One year growing the People of Color Employee Resource Group

Test Double’s People of Color Employee Resource Group (ERG) put its first year in the books! As one of the first ERGs at Test Double, this year was one to celebrate as we worked to build a community inside the company that focuses on progressing our careers and fostering interconnectedness.

Building community inside the ERG

As a 100% remote company, it can be easy to become isolated as you get heads-down on work. The ERG works to build interconnectedness between the people of color in Test Double. We hold regularly recurring meetings that cover lots of topics. Sometimes we use icebreakers or games to get to know each other better. Other times, we hold brainstorming sessions…

AkitaOnRails.com 

[Akitando] #127 - Como Funciona o Boot de um Linux? | O que tem num LiveCD?

Instalar distros Linux hoje em dia é muito fácil. Só bootar do pendrive, clicar em "próximo", "próximo" e pronto, tá tudo instalado e funcionando. Qualquer um consegue instalar na maioria das configurações modernas de hardware.

Porém, isso não te ensina nada e ao final você continua não sabendo absolutamente nada sobre o que é um Linux e o que de fato ele faz. Como é o processo de boot? Quais softwares estão envolvidos nesse processo? E mais importante: o que posso fazer quando alguma coisa dá errado? Quais ferramentas tenho à minha disposição?

Hoje é o dia de finalmente você começar a entender como sua máquina realmente funciona.

== Conteúdo

  • 00:00 - Intro
  • 01:11 - CAP 1 - Instalar…
BigBinary Blog 

Three case studies of debugging redis running out of memory

In this blog we would be discussing three separate case studies of Redis runningout of memory. All the three case studies have videos demonstrating how thedebugging was done.

All the three videos were prepared for my team members to show how to go aboutdebugging. The videos are being presented "as it was recorded".

First Case Study

When a job fails in Sidekiq, Sidekiq puts that job inRetrySet and retries thatjob until the job succeeds or the job reaches the maximum number of retries. Bydefault the maximum number of retries is 25. If a job fails 25 times then thatjob is moved to the DeadSet.By default Sidekiq will store up to 10,000 jobs in the deadset.

We had a situation where Redis was running…

Island94.org 

Reflections on Brompt, 2022

In response to a r/advancedentrepreneur thread, I wrote up some reflections on Brompt in response to “How well did this project do?”:

Not well. I dunno how much help this is, but my thoughts about the experience are:

People who are already inconsistently posting likely aren’t searching for a solution. It would be better to target overachievers who want to get to the next level, than lift up underachievers to just ok. Nagging people doesn’t work on it’s own.

I think “post daily/regularly” isn’t much of a goal. I think it would be better to tap into the actual outcome they want (“top influencer”, “alternative income stream”) and then help pave that path within your service, of…

Julia Evans 

Why do domain names sometimes end with a dot?

Hello! When I was writing the zine How DNS Works earlier this year, someone asked me – why do people sometimes put a dot at the end of a domain name? For example, if you look up the IP for example.com by running dig example.com, you’ll see this:

$ dig example.com
example.com.		5678	IN	A	93.184.216.34

dig has put a . to the end of example.com – now it’s example.com.! What’s up with that?

Also, some DNS tools require domains to have a "." at the end: if you try to pass example.com to miekg/dns, like this, it’ll fail:

// trying to send this message will return an error
m := new(dns.Msg)
m.SetQuestion("example.com", dns.TypeA)

Originally I thought I knew the answer to this (“uh, the…

Ruby in Better Programming on Medium 

Why You Should Stop Using ActiveModel Validations in Ruby on Rails

An in-depth guide on the benefits of switching

drake meme, saying no — caption : activemodel validations. saying yes — postgresql constraintsimage from imgflip

Ruby on Rails is great for many things, and as many of you know, validations in models are cool because they are simple, fast to implement, and easily testable.

But they also suck.

Note: This article is only viable if you’re using PostgreSQL. If you’re using SQLite or MySQL, STOP.

What Are They?

Validations are methods like validates , validates_associated and such, which will check the instance against some logic (can be uniqueness, the format of a string, or your own custom logic) and allow or disallow its insertion into the database.

There are many downsides to using model validations. Let’s see them together!

It’s Only Viable at…

Getaround Engineering 

Building a modular multiple flows wizard in Ruby

Wizards are a common component in a lot of applications. Either for signing up new users, creating products, purchasing items and many more.

They can be tricky to manage once they get bigger and more complex. At Getaround, we have several wizards which don’t share their architecture. A common architecture cannot fit every use case with different needs, flow, and user experience.

To list new cars on our platform, hosts provide multiple pieces of information on the vehicle, themselves, and their needs. We may ask for more information or skip some steps. Such constraints lead to complexity and difficulty in handling and testing every variation.

After multiple iterations, we ended up with a…

Short Ruby Newsletter 

Issue #9 - 5-11 September 2022

Hello,

I’m Lucian (@lucianghinda on Twitter), and I am the curator of this newsletter.

Last week I launched Code Summaries, where I summarise technical articles about Ruby with code.

If you want to see a short version of this newsletter with only the content that has code, you can see it here. It is a presentation that has one tweet per slide uploaded to speakerdeck.com.

This edition was created with support from @adrianthedev from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and from @jcsrb, who sent me recommendations to include in the newsletter.

If you have any feedback or ideas about this newsletter, please reach out on Twitter or via email at hello@shortruby.com


👉 Xa…

BootrAils 

Rails faker gem overview

What is Faker?

During the development process, it is often necessary to test the application to work with real data. Moreover, the data should be as close as possible to the real ones, both qualitatively and quantitatively, especially if we want to add hundreds of records to our database. Luckily, there is a gem called Faker, that greatly simplifies the work of filling the database with such data (phone numbers, email, usernames, etc.) that you can use in your tests. As it mentioned in the repository description, Faker generates data at random, so returned values are not guaranteed to be unique by default. But you can explicitly specify when you require unique values following the…