Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Josh Software 

The future of Software Testing -: Script-less Test Automation

In the recent years, there were limitless changes in the world of technology. The same has happened in the world of software testing where Test Automation has evolved to release a software product faster with the highest quality.  Technological innovations have lived up to our wishes and demands! One such example is Script-less Automation Testing. Today’s … Continue reading The future of Software Testing -: Script-less Test Automation
Dmitry Ishkov 

Turbocharge HTTP requests in Ruby

article logo

The problem

The slowest part in many applications is I/O, especially network I/O. We spend a lot of trying to make sure we reduce the number of calls and cache results of API calls to 3rd party services and resources.

Imagine we want to get data from Rick and Morty API. In this article, we are going to speed up subsequent requests to this API by almost 4x times.

The solution

And yet there's a trick that even very senior developers and popular API library/clients forget about that can shave off precious time of your network calls built right into HTTP.

Establishing an HTTP connection is very costly, especially if it uses TLS. This is a fixed price added to your HTTP calls…

Remote Ruby 

Joined by Andrea Fomera, Tony Hawk, and starting a Rails Hackathon!

[00:00:49] What an interesting week for Andrew! Find out exactly what happened to him and all about his “concerns” he had at work. 
[00:07:41] Chris was on Twitter this week talking about maybe bringing back “Rails Rumble” and he would love to make it happen but would need help. 
[00:12:20] We find out if anyone has participated in a Hackathon before. Chris and Jason talk about one time they tried to have their own Hackathon and what happened.
[00:18:27] Andrea, the “Caddy Expert,” tells us all about Caddy and how Caddy 2 has the built in API. 
[00:22:21] Andrea talks about a “proof of concept” she put together instead of using an API.
[00:24:53] Andrew wonders if Caddy is just a…
Saeloun Blog 

React 17 internally uses the browser's focusin and focusout events for onFocus and onBlur events

In React, the onFocus event is called when the element receives focus and onBlur event is called when focus has left the element. There are 4 types of native focus events, focus/blur which do not bubble and focusin/focusout which bubble.

Before React 17, the onFocus and onBlur events were internally mapped to focus and blur events in the capture phase, giving an impression as if the events bubbled.

This has lead to confusion and several problems related to relatedTarget.

In the world of Keyboard accessibility, relatedTarget plays an important role. IE 9-11 has native support for relatedTarget in focusin and focusout, but in React’s onBlur event, its value is null. This is because React c…

Awesome Ruby Newsletter 

💎 Issue 260 - The room where it happens: How Rails gets made

Ruby Weekly 

How Rails gets made

#​552 — May 13, 2021

Read on the Web

Ruby Weekly

The History of RSpec — The story of RSpec’s emergence is one of the most organic developments we’ve ever read. Steven is full of gratitude (along with some regrets) about his contribution and how the community ran with it.

Steven R. Baker

The Room Where It Happens: How Rails Gets Made — Richard is a Rails committer (not core member) writing about his observations of how Rails gets made along with his observations on current events in an effort to add to the conversation about the framework’s future (see last week’s issue for more on said events).

Richard…

Engine Yard Blog 

Container Adoption Trends & Best Practices: The DevGraph Webinar Series

 

All Ruby Podcasts by Devchat.tv 

Becoming the Go-To Person in Your Technology Area - BONUS

Chuck was on a strategic call with one of his potential coaching clients talking about cryptocurrencies and realized that this is one of the major reasons that people want to become influencers. Or, rather, that many people aspire to make a difference and/or make money and the best way to do that is to become the person people go to for what you do.

So, how do you become the first person people think of when they think of that thing you know how to do? Let Chuck tell you.

Panel

  • Charles Max Wood

All Ruby Podcasts by Devchat.tv 

Building a UDP Server with Ruby Ractors with Claus Lensbøl - RUBY 497

Claus Lensbøl is a Danish Devops engineer who built a UDP server using Ractors--a new feature in Ruby 3.0. Ractors is a method of getting concurrency in Ruby. It's what threads should have been to give us the ability to use multiple cores with one Ruby program without forking into multiple processes.

Panel

  • Charles Max Wood
  • John Epperson

Guest

  • Claus Lensbøl

Sponsors

Links

Picks

Engine Yard Blog 

Services, the Missing Element in Rails Applications: A Discussion with Riaz Virani

 

Jemma Issroff 

Ruby Garbage Collection Deep Dive: Object IDs

Through the Ruby GC Deep Dive series we’ve examined different strategies Ruby uses for its garbage collection. In this post, we’ll take a quick detour from GC strategies and instead examine the implications of these strategies on object_ids.

Every Ruby object gives us access to an object_id as a unique identifier for a specific instance of an object. If we read the Ruby docs, we can see that Object#object_id guarantees uniqueness and consistency of object_ids across objects. Explicitly, the docs say, “The same number will be returned on all calls to object_id for a given object, and no two active objects will share an id.”

Special Objects

In Ruby there are certain types of objects which…

RubyGems Blog 

April 2021 RubyGems Updates

Welcome to the RubyGems monthly update! As part of our efforts at Ruby Together, 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 April.

RubyGems News

This month in RubyGems, we released new versions for RubyGems v3.2.16, v3.2.17 and corresponding versions for Bundler (v2.2.16 and v2.2.17).

As part of those releases, we made the following improvements and fixes:

  • fixed an issue affecting custom sidekiq-pro gem servers, which was preventing users from upgrading their sidekiq-pro version - #4563.
  • made Bundler more secure by preventing any credentials from being logged to the screen, thus…
Schneems - Programming Practices, Performance, and Pedantry 

The room where it happens: How Rails gets made

Today I’m going to share my perspective on how Ruby on Rails is developed and governed and how I feel the Basecamp “incident” impacts the future of Rails. I’m going to start out telling you what I know for sure, dip into some unknowns, and dive into some hypotheticals for fun.

OmbuLabs Blog 

The O in Solid

In a previous post we considered the practical value of the Single Responsibility Principle (SRP). This is the second post in this series where we take a deeper look at each of the SOLID principles.

Robert C. Martin (a.k.a. “uncle Bob”) refers to the O in Solid as the heart of Object Oriented (OO) design. He goes so far as to say that this principle improves reusability and maintainability more than any other OO principle. You most likely already know that the O in SOLID belongs to the Open/Closed Principle (OCP).

We often hear about SRP or DRY (don’t repeat yourself) but seemingly less often about OCP. It turns out that this principle lays the foundation for many of the OO best…

Ruby on Rails Podcast 

370: Samvera with Lea Ann Bradford

Lea Ann Bradford is a senior software developer for Notch8, an agency that leverages the Samvera open source community. Lea Ann tells her story of learning to code after being a stay at home mom and she educates Brittany on all things Samvera.

Links for this episode:

Brought to you by:

Raygun

Save time, money, and sanity by visiting Raygun.com/ruby and…

Ruby Magic by AppSignal 

Three Ways To Avoid Duplicate Sidekiq Jobs

Chances are, if you are writing Ruby code, you are using Sidekiq to handle background processing. If you are coming from ActiveJob or some other background, stay tuned, some of the tips covered can be applied there as well.

Folks utilize (Sidekiq) background jobs for different cases. Some crunch numbers, some dispatch welcome emails to users, and some schedule data syncing. Whatever your case may be, you might eventually run into a requirement to avoid duplicate jobs. By duplicate jobs, I envision two jobs that do the exact same thing. Let’s dive in on that a bit.

Why De-Duplicate Jobs?

Imagine a scenario where your job looks like the following:

1
2
3
4
5
6
7
8
9
10
11
class BookSalesWorker
Saeloun Blog 

Ruby 3.1 evaluates multiple assignments from left to right

Single assignment

In the case of single assignment, Ruby evaluates the left-hand side before the right-hand side.

In the below example, the last expression calls lists, then data , then []= on the result of lists.

  lists = ['ruby', 'python', 'scala']
  data = 'rust'
  lists[1] = data

Before

Multiple assignments didn’t work this way. Let’s checkout the below example.

  lists[1], tag.priority = data, num

Before Ruby 3.1, the above expression would be evaluated in the following order:

  1. data
  2. num
  3. lists
  4. []= called on the result of lists
  5. tag
  6. priority= called on the result of the tag

After

Starting with Ruby 3.1, multiple assignments evaluation order has been made consistent…

Greater Than Code 

234: Civil Society and Community Relationships with Michael Garfield

02:13 - Michael’s Superpower: Being Able to Creatively Digest and Reconstruct Categories

09:39 - Recognizing Economic Value of Talents & Abilities

18:49 - The Edge of Chaos; Chaos Theory

  • “Life exists at the edge of chaos.”

23:23 - Reproducibility Crisis and Context-Dependent Insight

28:49 - What constitutes a scientific experiment?

38:03 - The Return of Civil Society…

Julia Evans 

What is the OSI model?

Today I tweeted something about how the OSI model doesn’t correspond well to the reality of how TCP/IP works and it made me think – what is the OSI model, exactly? From reading some of the replies on Twitter, it seems like there are at least 3 different ways to think about it:

  1. A literal description of how TCP/IP works
  2. An abstract model that you can use to describe and compare a lot of different networking protocols
  3. A literal description of some computer networking protocols from the 1980s that are mostly no longer used today

In this post I’m not going to try to argue that any one of these is “really” what the OSI model is – it seems like different people think about the OSI model in…

Kir Shatrov 

Global infrastructure expansion

Having been working on the global expansion of Shopify’s infrastructure footprint, I noticed there’s at least two patterns of you can follow when deploying a web service globally for both latency and reliability improvements.

Single source of truth + edge compute

You leverage the edge compute (either with your own proxy deployment or with CloudFlare) to cache responses of your app that’s running in a single location.

The challenge comes with expiring those edge-cached responses: once the data has changes in the source of truth, it has to tell every edge that cache has to be expired.

Having 200+ points of presence on the edge (the Cloudflare’s number) combined with frequent updates could…

Long live Ruby 

Your first A/B test with Rails

If you are not yet familiarized with the A/B tests, let me introduce you to this topic in few sentences. While unit, integration, or acceptance tests ensure that your application behaves as you expect it, A/B tests help you to choose which version of the element in your application works better. For example, if you have a mailing list and wondered what text you should put on the subscribe button to encourage more people to click on it, A/B tests are your friend. They will help you to test different options and choose the one that your users liked the most. How does it work in practice? It’s simple.
Kir Shatrov 

Materializing tables with Vitess

I wrote this post as I was playing with materializing tables in Vitess. I find that there’s not that many resources online that walk through Vitess features. I hope this post is useful for whoever is looking at Vitess capabilities.


Let’s imagine an example of the following schema in an abstract ecommerce app:

CREATE TABLE `products` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `tenant_id` bigint(20) DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `product_type` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

In the rendering layer of the ecommerce app, you may find the following query appear as a hot one:

SELECT DISTINCT product_type
FR…
Saeloun Blog 

Rails 7 ActiveSupport::Cache::MemCacheStore now accepts an explicit nil for addresses argument

For those using Dalli as cache store in Rails, this config should appear somewhat familiar:

config.cache_store = :dalli_cache, nil, { expires_in: 1.hour }

In the above code snippet, we passed nil for the addresses argument. But if we were to migrate to :mem_cache_store with the same config like below:

config.cache_store = :mem_cache_store, nil, { expires_in: 1.hour }

then the value of addresses would be [nil] instead of nil causing an exception when trying to access the cache.

> Rails.cache.fetch('user_id')
NoMethodError: undefined method `match' for nil:NilClass

Rails 7

This PR adds support for passing an explicit nil to mem_cache_store. This change makes migrating from :dalli_st…

Rebased Blog 

Using SQLite on the bus

Recently a friend asked me to find out a certain piece of data. Which bus route in Poznań is the longest? As I’m a massive ferroequinologist and public transport enthusiast, this question is right up my alley. However, this information is rarely accessible directly. Public transport planning is a complex...
RUBY3.dev 

Teaching Ruby to Beginners? Trying New Gems or Techniques? Use Bridgetown!

As a core member of the Bridgetown project, I realize I’m biased. I think every Rubyist who works on or even near the web should take a look—especially anyone who has current or past experience using Jekyll. But today’s post isn’t about Bridgetown per se but about how the next big release, v0.21 “Broughton Beach” (currently in beta and due out in late May), provides an intriguing new environment for teaching and learning Ruby and trying out new tools in the Ruby ecosystem.

Ruby Ruby Everywhere

One of the new features in Broughton Beach which is germane to this discussion is the ability to write web pages in pure Ruby. Previously, you could write a webpage in a template language such as…

BigBinary Blog 

Ruby 3.1 adds Array#intersect?

Ruby 3.1 introduces the Array#intersect? method which returns boolean valuetrue or false based on the given input arrays have common elements in it.

We already knowArray#intersection or Array#&methods which are used to find the common elements between arrays.

=> x = [1, 2, 5, 8]=> y = [2, 4, 5, 9]=> z = [3, 7]=> x.intersection(y) # x & y=> [2, 5]=> x.intersection(z) # x & z=> []

The intersection or & methods return an empty array or array having thecommon elements in it as result. We have to further call empty?, any? orblank? like methods to check whether two arrays intersect each other or not.

Before Ruby 3.1

=> x.intersection(y).empty?=> false=> (x & z).empty?=> true=> (y & z).any?=> false

Afte…

The Bike Shed 

292: Debugging with Joël Quenneville

On this week's episode, Steph and Chris are joined by fellow thoughtbotter, Joël Quenneville, to discuss all things debugging. Joël is helping publish a weekly debugging blog series and in this conversation they discuss how the series got started, technology agnostic debugging strategies, writing less bug-prone software, and speculate if Joël moonlights as a hockey coach.

Support The Bike Shed

Rails with Jason 

095 - Writing for Developers with Jordan Raine of GitHub

In this episode I talk with Jordan Raine, Senior Developer at GitHub, about writing. We talk about writing PRs and writing emails. We also discuss some of our favorite books and authors.

Links:

Test Double | Our Blog 

Working strategically through Rails upgrades

In the past few years, I’ve seen a huge improvement in how teams upgrade their Rails apps. Instead of starting a new branch and seeing where it goes, we can now use tools like Bootboot to do Rails upgrades alongside everday development.
Engine Yard Blog 

The Ruby Unbundled Series: Services vs. Objects - The Battle for Decomposition and Reuse

Before finding a home with Ruby, I was a longtime Java developer almost from the very beginning of the language. So it certainly caught my attention when I read the opening line of this articleby Ilya Suzdalnitski: “C++ and Java probably are some of the worst mistakes of computer science.” Part clickbait, part theme of picking on any language to entertain readers (none are perfect), and part truth.

John Nunemaker 

Rails Feature Flags: Now So Flippin' Easy You Won't Believe It

Rails Feature Flags: Now So Flippin' Easy You Won't Believe It

As I said in the title, getting started with feature flags in your Rails apps has never been easier. With the latest release of Flipper (0.21), the golden path is all handled by simply bundling the gems you need.

If this version had a name, it would probably be convention over configuration. I'm going to take you through all the automatic ✨ now. So read on and enjoy.

Automatic Adapters

In previous versions of Flipper, you had several decisions to make to get started:

  • Which adapter should I use? What even is an adapter?
  • Should I include memoization? How do I do that?
  • Should I preload all features, some features or no none?

No more. After more than a decade of using feature flags and eight years…

Code with Jason 

Rubyists to follow on Twitter

If you’d like to keep your finger on the pulse in the Ruby world, here’s a list of Rubyists you can follow. The list is in alphabetical order by last name.

The list

Bozhidar Batsov
Author of RuboCop.

Rob Bazinet
Rubyist, blogger.

Nate Berkopec
Rails performance expert, author of the Complete Guide to Rails Performance.

Mike Buckbee
Creator of Expedited Security.

Jason Charnes
Co-host of the Remote Ruby podcast.

Ken Collins
Principal Engineer at Custom Ink.

Dave Copeland
Author of Sustainable Web Development
with Ruby on Rails
.

Peter Cooper
Creator of Ruby Weekly.

Andy Croll
Organizer of Brighton Ruby.

Andrew Culver
Creator of Bullet Train.

Vladimir Dementyev
Developer at Evil Martians,…

And…

kukicola.io - Writing about ruby, rails and other web technologies 

Useful Active Support features you may not have heard of

Active Support is a really powerful library that is a part of Rails framework. It contains many useful core extensions that empower standard ruby objects with additional features. For example it adds hours method to Integer class and allows us to create simple and readable code like created_at < 2.hours.ago instead of created_at < Time.current - 2*60*60. Today we’ll dive beyond that and focus on many utilities it includes, which can be useful in your next Rails project or any other ruby app.

Callbacks

We are all familiar with callbacks. before_action in the controllers and after_save in the models are commonly seen in Rails applications. I’m not going to arbitrate if they are good or bad…

Tom Dalling 

Start With High-Level Tests

Rule Of Thumb

Start with high-level tests, and step down to lower levels when the implementation is stable.

Josh Software 

Creating {legacy} static build via docker and deploying with mina-scp

I am sure! Many of our applications have turned into a legacy codebase, such applications might have some outdated scripts or build process that might need frequent maintenance and updates.  In this post, I will walk you through the steps with which we can move our frontend build creation script into the docker container and … Continue reading Creating {legacy} static build via docker and deploying with mina-scp
Dmitry Ishkov 

Next.js: restrict pages to authenticated users

Many websites have pages that need to be restricted to authenticated users, for example profile pages or dashboards.

Next.js web framework comes with a lot of functionality built-in JS compilation, rendering code on server and caching.
When it comes to most other aspecs, it's up to a programmer to build, including such needed functionality as restricting access to some pages only to authenticated users.

In this article we are going to build just that: a function that augments a page object, that could be used like that:

Here's the implementation in TypeScript:

In order to make it work on server we are going to need one more utility function fetchWithCookies.
When making HTTP…

With a Twist 

Mystery Guest Development Edition

Mystery Guest is the name of an anti-pattern that often appear in tests. In short, it is caused by non explicitly declaring or naming a value, which is tested over that faulty declaration. The issue is not apparent at first, as the test is created at the same time as the fixture or factory that supports it. Eventually, when a change is needed in that support object to test something else, the change unintentionally breaks the first test.

For a test which verifies that the full_name of a user is the combination of first_name and last_name, those two properties need to appear explicitly on the test setup. Even if you have user factory, you are not testing the factory, but your own user with …

Honeybadger Developer Blog 

React on Rails: Building a Simple App

Companies that build the entire front-end side of their applications often choose the same framework, such as Rails, to build the back-end. For many years, this has been the best and most reliable option.

Today, tons of libraries and frameworks, in a constantly evolving front-end universe, allow developers to select different platforms for both the back and front-end and easily integrate them.

React has become the titan of the front-end Pangea. If you work with Ruby on Rails, chances are that you once needed to switch the default Rails pages to React code (or any other front framework). Perhaps, you simply love Rails + React features and would love to integrate the power of both techs…

Andy Croll 

Wrap your environment variables in a settings object

In our applications, we often use environment variables to configure the application itself or connections to third party services. These values are then accessed through the special ENV hash provided by Ruby.

Instead of…

…using environment variables in your code:

app/views/layouts/application.html.erb

...
<% if ENV["ANALYTICS_TOKEN"] %>
<script>
  window.analytics_token = <%= ENV["ANALYTICS_TOKEN"] %>
  ...blah_js...
</script>
<% end %>
...

Use…

…an object to wrap your configuration:

config/initializers/settings.rb

class Settings
  class << self
    def analytics?
      !!analytics_token
    end

    def analytics_token
      ENV["ANALYTICS_TOKEN"]
    end
  end
end

app/views/la…

Test Double | Our Blog 

Profile: River Lynn Bailey

Name: River Lynn Parrhesia Bailey Designation: Agent 0069 Role: Senior Software Consultant Special Skills: Empathy Driven Consulting, Development and EDI Work Aliases: Mx River Lynn Location: Waco, TX Favorite Emoji: 🤔
Dmitry Ishkov 

Phone Authentication in Ruby

Using SMS to authenticate a user has the following benefits:

  • Everybody has a phone.
  • Users don't have to remember passwords.
  • Protect against robots & duplicate accounts.
  • Familiarity.

You should not use SMS a sole authentication method for systems that require high-security.

What I am going to cover in this article is how to make an API that generates "phone tokens" that can be used to sign-in / sign-up. This way you don't need to create a user record before a phone is verified.

User stories

Below is 2 user stories we are going to cover.

As a returning user.
I want to sign-in.
I go to the login screen and enter my phone.
I receive an SMS with…

Jemma Issroff 

Ruby Garbage Collection Deep Dive: Compaction

So far in this series, we’ve discussed GC::INTERNAL_CONSTANTS, the Tri-Color Mark and Sweep algorithm, Generational GC and Incremental GC. We’ll build on what we’ve learned in this post about the newest addition to Ruby’s GC: compaction.

Fragmentation

Before we dive into compaction, we need to learn about fragmentation. Fragmentation is the term we use to describe memory when it’s allocated non-contiguously. This means that there are gaps in memory between where we store meaningful information, and where we don’t store meaningful information.

More concretely, in the Ruby Heap, fragmentation is when there are free, unallocated slots (without RVALUES) in between allocated slots (with RVALU…

Awesome Ruby Newsletter 

💎 Issue 259 - A Day in the Life of a Ruby Object by Jemma Issroff

zverok with ruby 

I forgot how to spellcheck

I spent a year building a spellchecker, and all I got is some grumbling to share.

When I started rebuilding the world’s most popular spellchecker, I had several goals. But the main one was: understand spellchecking better, share this understanding with others, and, ideally, push spellchecking development a little bit.

I spent most of 2020 building and documenting Spylls. Then, I am spending my 2021 on the series of articles about the details of Hunspell’s algorithms.

After all those months, I can proudly state that now I understand less about how the spellchecking should be done “right” in 2021 than I’ve understood at the beginning of the project. But I am almost sure it shouldn’t be…

Ruby Weekly 

❤ Sam Stephenson

#​551 — May 6, 2021

Read on the Web

😬 Last week I linked to what felt like a very tangential (to Ruby) story about Basecamp which I knew many in the Ruby community would be discussing, even if it wasn't about Ruby. Since then, the story has developed further with people leaving the Rails core team and DHH's role and leadership of the Rails project put into question. Therefore, we lead with it below.
__
Peter Cooper, editor

Ruby Weekly

On the Effects of the Last Week on Ruby on Rails — As mentioned in my intro paragraph (above), the past week has seen a lot of developments in the story around…

  • Sam Stephenson, a true Ruby powerho…
Dmitry Ishkov 

Encrypt & Decrypt text in Ruby

If you want to pass some information to a client that you don't want the client to read or temper with, read on!

The usage of our TextEncryptor is straightforward:



data = { ... }
serialized_data = JSON.dump(data)
encoded_data = TextEncryptor.encrypt(serialized_data)

# ...

serialized_data = TextEncryptor.decrypt(encoded_data)
data = JSON.parse(serialized_data)

Implementation:


One of the ways I use this is to store a proof that a phone number is verified on client side and allow exchanging that encoded phone number token to login or signup. You can read more about this in one of the following blog posts.


Thank you for reading!

All Ruby Podcasts by Devchat.tv 

Don't Let These Things Keep You From Podcasting - BONUS

Charles talks about the things that get developers stuck when they're trying to start their podcast or other influencer channel. He explains how to get around having those things hamper your journey.

Panel

  • Charles Max Wood

All Ruby Podcasts by Devchat.tv 

Why Write Rails View Tests with Nikola Đuza - RUBY 496

We test our Rails Controllers, Models, Helpers, and Services. But, why don't we test our views? Nikola Đuza has started testing his and explains how he does it and what he's learned about the process. He also explains what confidence it's added for him when writing his Rails code.

Panel

  • Charles Max Wood
  • Dave Kimura 
  • Luke Stutters

Guest

  • Nikola Đuza

Sponsors

Links

Picks

  • Charles- Get outside
  • Charles- Go to a farm
  • Charles- Go to nature
Riding Rails 

Rails versions 6.1.3.2, 6.0.3.7, 5.2.4.6, and 5.2.6 have been released!

Hi everyone! Rails versions 6.1.3.2, 6.0.3.7, 5.2.4.6, and 5.2.6 have been released!

These releases contain important security fixes, so please update when you can! Here is a list of the issues fixed:

Here are the checksums for the gems:

$ shasum -a 256 *-6.1.3.2.gem
0792e3dde6f85d2fec45dd048b0fc84b6ecec94f5011bf44c210f278c2522697 …
OmbuLabs Blog 

Behind The Scenes: Rails UJS

Rails UJS (Unobtrusive JavaScript) is the JavaScript library that helps Rails do its magic when we use options like remote: true for many of the html helpers.

In this article I'll try to explain the main concept of how this works to make it transparent for the user. Knowing a bit about the inner workings can help when debugging issues and also if we need to do something more complex than the provided interactions but reusing what's provided.

If you are using an old version of Rails and you are still using jquery-ujs, some code will not reflect how it does the magic, but most of these concepts apply as well (rails-ujs is a re-implementation of jquery-ujs removing the jquery dependency).

Boring Rails: Skip the bullshit and ship fast |  

Quickly explore your data with `uniq` and `tally`

A common question you may want to answer on user-input data is: what values have been entered and how many times is each one used?

Maybe you have a list of dropdown options and you want to investigate removing a rare-used option.

Ruby has two handy methods that I reach for often: uniq and tally.

Usage

The uniq method operates on an enumerable and compresses your data down to unique values.

Outreach::Task.all.map(&:status).uniq
=> ["Confirmed w/o Outreach",
 "Awaiting Outreach",
 "Responded",
 "No Response Expected",
 "Follow-up",
 "Awaiting Reply"]

While most developers are familiar with uniq, the tally method is one of the best kept secrets in Ruby. The tally method takes an…

RubyGems Blog 

3.2.17 Released

RubyGems 3.2.17 includes enhancements and documentation.

To update to the latest RubyGems you can run:

gem update --system

To install RubyGems by hand see the Download RubyGems page.

## Enhancements:

  • Only print month & year in deprecation messages. Pull request #3085 by Schwad
  • Make deprecate method support ruby3’s keyword arguments. Pull request #4558 by mame
  • Update the default bindir on macOS. Pull request #4524 by nobu
  • Prefer File.open instead of Kernel#open. Pull request #4529 by mame

## Documentation:

  • Fix usage messages to reflect the current POSIX-compatible behaviour. Pull request #4551 by graywolf-at-work

SHA256 Checksums:

  • rubygems-3.2.17.tgz
    e4ceef4d6204de…
Ruby on Rails Podcast 

369: Frontend Bundlers & Snowpacker with Konnor Rogers

Konnor Rogers is a software developer for Veue Inc. He is also the creator of Snowpacker, and he has a deep love for open source. He breaks down Frontend bundlers for Brittany and the up and coming vite_ruby.

Links for this episode:

Brought to you by:

ExpressVPN

ExpressVPN is an app that reroutes your internet connection through their secure servers so your ISP can’t see the sites you visit.

If you visit https://EXPRESSVPN.com/RUBY right now, you can get an extra three months of ExpressVPN for free! Support the show and protect yourself at https://EXPRESSVPN.com/RUBY.

Greater Than Code 

233: Diversity, Equity, and Inclusion Matter with Jess Szmajda

01:22 - Jess’s Superpower: Playing ANY Instrument

  • Music & Technology
  • Cultural Expoloration

06:03 - Language Community Ethos (MINASWAN)

13:24 - Inclusive Language: Language Matters

17:19 - Active Listening and Expressing Point-of-View, and Using Loudness

  • Vocally For
  • Vocally Against
  • Quiet For
  • Quiet Against

21:51 - Shining Light on Marginalized People & Voices

  • BULQ
  • Metacognition: Asking ourselves, “What are we not thinking about?”
  • Leadership
  • Changing Mental Patterns; Take a Different Path

31:30 - Benefits of Having Diverse Teams (Resources) & Risks of Homogeneity

Saeloun Blog 

Rails 7 transforms a Ruby hash into HTML attributes for ERB interpolation

One of the basic things we learn as a Rails developer is how to interpolate bits and pieces of Ruby code into our template file, which is ERB. There are many other template engines apart from ERB, such as HAML and Slim, but since ERB is the default for Rails, the examples shown below use the ERB syntax.

Let us consider the example of displaying an image of my pet dog 🐶. Assume that we have the following attributes in a hash.

  pet = { image_url: "https://data.whicdn.com/images/23516263/original.jpg",
  name: "Pommya", breed: "Pomeranian", color: "white" }

Before

The above hash values can be added to HTML img tag as below:

<img src="<%= pet[:image_url] %>", alt="<%= pet[:name] %>",
  da…
Hanami 

Announcing Hanami v2.0.0.alpha2

Hello, Hanami community! It is my great honor to make my first post here and announce the release of Hanami v2.0.0.alpha2! 🎉

It’s been a little while since the last alpha release, but we’ve been hard at work, and the close collaboration between the Hanami, dry-rb, and rom-rb teams has been going exceedingly well. Together, we’re delighted to present a revolutionary vision for Hanami 2.0! In this alpha, we have:

  • A completely rewritten application core, offering advanced application-level state management and code loading capabilities
  • An always-there auto-injection mixin, making it easy to model your behavior as functional, composable objects
  • Built-in application settings with first-class…
  • New Slices
Frank’s blog 

Clean up HTML class attributes in Ruby on Rails

I keep on discovering handy view helpers in Ruby on Rails while developing Callcounter. A few weeks back I remembed cycle and last week I discovered a new helper that was introduced in Ruby on Rails 6.1: class_names.

Beautify your views

Most of us will probably recognize the class name spaghetti that starts to arise when your project grows. Things like this will become littered throughout your views:

<li class="item <%= 'active' if @active %>
    <%= 'disabled' if @unpaid_user %>">

Not exactly readable anymore, right? Well, thats what class_names is trying to fix. You just pass it a hash with the class names as keys and conditions as values. Look how nice!

<li class="<%= classs_name…
Rails with Jason 

094 - Stimulus with Jesse Spevack, Staff Engineer at Ibotta

In this episode I talk with Jesse Spevack, Staff Engineer at Ibotta about Stimulus, conference talks, and hiring developers.

Links:

Long live Ruby 

Rails under the hood: Routes

Routes engine is the core part of every Rails application. Thanks to the config/routes.rb file, we can easily define the application’s routes using special DSL. Let’s take a closer look at the coder under the hood to understand a bit of Rails’ magic.
BigBinary Blog 

Rails 6.1 adds invert_where method

Rails 6.1 adds an invert_where method that will invert all scope conditions.

Let's see an example.

class User  scope :active, -> { where(accepted: true, locked: false) }end>> User.all=> #<ActiveRecord::Relation [#<User id: 1, name: 'Rob', accepted: true, locked: true>#<User id: 2, name: 'Jack', accepted: false, locked: false>#<User id: 3, name: 'Nina', accepted: true, locked: false>#<User id: 4, name: 'Oliver', accepted: false, locked: true>

Now let's query for active and inactive users

>> User.active# SELECT * FROM Users WHERE `accepted` = 1 AND `locked` = 0=> #<ActiveRecord::Relation [#<User id: 3, name: 'Nina', accepted: true, locked: false>]>>> User.active.invert_where# SELECT * FROM Users…
BigBinary Blog 

Rails 7.0 adds encryption to Active Record models

Before Rails 7.0, to add encryption on attributes of ActiveRecord models, we hadto use third-party gems like lockbox whichserved the purpose but at the cost of an additional dependency.

Before we delve deeper, let's take a look at some terms related toencryption:

  1. Encrypt: to scramble a message in a way thatonly the intended person can extract the original message.
  2. Decrypt: to extract the original message from anencrypted one.
  3. Key: a string of characters used to encrypt/decrypt a message.
  4. Cipher: an algorithm used to encrypt and decrypt a message;RSA, Blowfish, and AES are some well-known examples.
  5. Deterministic: a process with guaranteed results;the sum of a set of numbers never changes.
  6. Non-deter…

Rails 7.0

Rails 7.0 adds encryption to attributes at the model level. By default, itsupports encrypting serialized attribute types using the non-deterministicAES-GCM cipher.

To use this feature, we have to set the key_derivation_salt, primary_key, anddeterministic_key variables in our environment file. These keys can be generated byrunning …

Let's enable…

dry-rb news 

Introducing dry-files

We talked several times about the union of dry-rb + ROM + Hanami, well today we can share good news on that front: introducing dry-files.

It's a gem that abstracts low level file manipulations.

The code was originally created for hanami-utils, as a way to power Hanami command line. Then it was moved to dry-cli, when it was extracted from the Hanami code base. Today it finally made its own debut as a standalone gem.

dry-cli is a powerful framework to build Ruby command line interfaces. We use it as the main engine for the Hanami CLI, which also needs code generators. The initial idea was to have this optional dry-cli library to support code generators via file manipulations. But then we…

Dmitry Ishkov 

Faster Google Maps load times

Google Maps is notoriously slow. The moment you add a Google Map to your page you can cut your Lighthouse performance score in half.

There are several ways you can fight with it:

  • Add async/defer to your Google script - certainly helps, but no much. This technique is very common so I won't be talking about it.
  • Loading the map only when a user scrolls to it. This works well the map is located below the fold. Code.
  • Using a static google maps image. There are cases when you might not need an interactive map and an image is all you need. The API for it is surprisingly versatile. Code.
  • Skipping fonts loading.…

By using these tricks you can achieve much better page performance (and…

Hi, we're Arkency 

Semantic blind spot in Ruby case statement

Semantic blind spot in Ruby case statement

Some time ago I’ve stumbled upon an article on case statements in Ruby. The author presents there an example of case statement with ranges:

case number
when (0..3)
  'low value'
when (4..7)
  'medium value'
when (8..10)
  'high value'
else
  'invalid value'
end

The ranges actually read well. I’d even write similar case statement myself. And yet an avid mutant user may tell you there’s a “flaw” hidden there. Can you spot it?

Let’s pick one branch of that conditional for a closer look. Be it this one:

when (8..10) then 'high value'

Assume we also have 100% line coverage, reported by simplecov for that example. That’s rather easy to achieve:

def te…
Saeloun Blog 

Rails 7 adds disable_joins: true option to has_many :through association

We often use multiple databases in our Rails application. Rails 6 made it easier to connect to multiple databases.

Let’s consider a use case where:

  • User can create multiple posts.
  • Anyone looking at the post can add a comment - crowd-sourced comments.

In this case, we can store the crowd-sourced comments in a separate database, as comments can grow quickly and may need a different kind of data management approach.

The database.yml can be like below:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password: password

development:
  primary:
    <<: *default
    database: rails_demo_development
  crowd…

The models would look like below:

#…
The Bike Shed 

291: All Things Inertia.js with Jonathan Reinink

This week Steph's taking a quick break, but while she's off, Chris is joined by a special guest - Jonathan Reinink. Jonathan is the creator of Inertia.js. Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers, and listeners of the show will certainly have heard Chris rave about it on previous episodes.

Chris and Jonathan dig into what makes Inertia unique as compared to frameworks like Phoenix LiveView, Laravel Livewire, and Rails' Hotwire & Turbo. They also discuss how Inertia embraces the URL, the unique "protocol" nature of Inertia, and how to consider Inertia alongside native mobile applications.…

Test Double | Our Blog 

Why EDI work is super important to Test Double

Our mission is to improve the way the world builds software. This is intentionally vague because software is broken in many ways. It’s broken by building the wrong product, by the wrong people, for the wrong reasons, or for the wrong people.
Kir Shatrov 

Talking to Vitess over GRPC from Ruby

After you’ve got to run a simple Vitess cluster with a few databases, you might want to automate some of the stuff, for instance if you’re doing lots of resharding or vertical splits.

How do you script interactions with Vitess? You could have a Bash script do all the vtctlclient work, but at some point that would become fragile.

Vitess provides world-class Go APIs, but for something that I wanted to experiment with, Ruby was be a better fit.

In this post I wanted to share how I got to talk to Vitess through GRPC from Ruby.

GRPC adventures

GRPC relies on code generating. That’s a bit unusual if you come from the Ruby ecosystem but nevertheless.

You have to install the grpc-tools gem…

Boring Rails: Skip the bullshit and ship fast |  

Improving your Rails mailers with `email_address_with_name`

In almost all email programs, you can add a display name before your email address like so:

To: Matt Swanson <matt@example.com>

It’s a small touch, but it is a more human-readable way of addressing an email. Rails provides a helper utility to format email addresses in this style without resorting to manual string manipulation.

Usage

Use email_address_with_name to add a name in-front on an email address in a standard way

ActionMailer::Base.email_address_with_name("swan3788@gmail.com", "Matt Swanson")
=> "Matt Swanson <swan3788@gmail.com>"

This helper is available in all Rails mailers.

class UserMailer < ApplicationMailer
  default from: 'notifications@example.com'

  def welcome_ema…
Josh Software 

Native vs ImmutableJS vs Immer — Are libraries the way to go for immutability in React?

Maintaining immutability when dealing with objects and arrays is very important in React. It ensures that the DOM updates correctly and predictably. But when we have nested data structures, maintaining immutability in our data can get ugly, very fast. This article explores 3 approaches to immutability — doing it natively, using ImmutableJS (a library which … Continue reading Native vs ImmutableJS vs Immer — Are libraries the way to go for immutability in React?
Drifting Ruby Screencasts 

Building a Questionnaire

Using StimulusJS and nested forms, we create the first parts of a questionnaire. Dynamic surveys can be difficult to architect and maintain. In this episode, we take a simple approach to creating questionnaires.
Honeybadger Developer Blog 

Top Ten Git Tips & Tricks

This article complements ‘Understanding How Git Works’. Now that you have an understanding of the plumbing, it's time to level up your skills. Hopefully, these tips and tricks will increase your efficiency and productivity as a developer. It will help you spend more time coding and less time trying to decide whether to git merge or git rebase. Without further ado, let's get into it!

10. Blank commits

Have you ever found yourself making a small tweak to the README so that you can kick-off a build (or some other integration) and try to debug an issue? I used to do this fairly frequently, until I found out about the following command:

git commit --allow empty -m 'it works!'

This allows you…

Test Double | Our Blog 

Reduce State Management Footprint with React Query

As a consultant who has worked with React since 2014, I have been fortunate to see and work with many dozens of production React codebases. In that time, I’ve noticed many patterns of use (and pain) that crop up even between very different applications.
Riding Rails 

Rails Governance

As some questions have been raised about how the Rails project’s governance functions, we’d like to clarify how the team is structured and how we operate:

  • Ruby on Rails is an Open Source project run by the Rails Core team. In addition to the Core team we have two additional teams - the Committer team who can merge code changes, as well as the Issues team who can triage issues and merge documentation changes.

  • There are 11 members on the Core team who work for various employers or are independent consultants. We make decisions and work towards consensus as a team when needed. We each strive to make decisions that are best for the Rails framework and community. The members…

Kir Shatrov 

Throttling database load with Vitess

In his Percona Live 2020 talk, Shlomi Noach pointed out that he sees Vitess is an infrastructure framework that would let everyone get database capabilities that you’d otherwise have to build yourself.

At Shopify, we’ve built our own system that lets us keep track of database health and replication lag, to throttle clients (mostly, background jobs) accordingly. It took us quite a bit of efforts to build that and to make it work at scale to handle 1000s of MySQL hosts.

I’m really excited about technologies like Vitess (and its direction as an infrastructure framework) that could bring capabilities like throttling database operations to everyone, not just to large companies like Shopify and…

Hanami 

Announcing Hanami v1.3.4

Hello wonderful community!

Today we're happy to announce v1.3.4 🙌.

Bug Fixes 🐞

  • Fix generated config.ru require_relative statement
  • Fix Hanami::CommonLogger elapsed time compatibility with rack 2.1.0+
  • Fix generated tests compatibility with minitest 6.0+

Released Gems 💎

  • hanami-1.3.4

How to install ⌨️

$ gem install hanami
$ hanami new bookshelf

How to upgrade ⬆

$ bundle update hanami

Happy coding! 🌸

Julia Evans 

I put all of my comics online!

Hello! As you probably know, I write a lot of comics about programming, and I publish collections of them as zines you can buy at https://wizardzines.com.

I also usually post the comics on Twitter as I write them. But there are a lot of problems with just posting them to Twitter, like:

  • the pages are hard to find. For example, if you want to find the one on socat, you can search twitter and you’ll find it, but then you have to somehow magically guess what words I used in the tweet, and also sort through a bunch of other tweets.
  • they’re annoying to link to. Twitter isn’t really the best user interface for this sort of thing.
  • I can’t make updates. Twitter doesn’t have an edit button!
  • work…

If someone wants to see the page on socat, I’d really like them…

Ruby News 

CVE-2021-31799: A command injection vulnerability in RDoc

There is a vulnerability about Command Injection in RDoc which is bundled in Ruby. It is recommended that all Ruby users update RDoc to the latest version that fixes this issue.

Details

The following vulnerability has been reported.

RDoc used to call Kernel#open to open a local file. If a Ruby project has a file whose name starts with | and ends with tags, the command following the pipe character is executed. A malicious Ruby project could exploit it to run an arbitrary command execution against a user who attempts to run rdoc command.

Ruby users whose version of RDoc is affected by this issue should update to the latest version of RDoc.

Affected Versions

  • All…
Hi, we're Arkency 

Fighting the primitive obsession with Value objects

My previous post on read models intended to address something different, but I decided to focus on read model part and leave the other topic for a different one. There’s one thing which I dislike in the implementation. Using primitives to calculate the scores.

Projection

def calculate_scores(test_id, participant_id)
  RailsEventStore::Projection
    .from_stream(stream_name(test_id, participant_id))
    .init(-> { Hash.new { |scores, skill_id| scores[skill_id] = { score: 0, number_of_scores: 0 } })
    .when(
      SurveyExecution::AnswerRegistered,
      ->(state, event) do
        skill_id = event.data.fetch(:skill_id)
        state[skill_id][:score] += event.data.fetch(:score)
        

It accumulates the score in scope of a given skill so we can count the average and so on. This example is simplified, as…

solnic.codes 

WHOOPS! Thoughts on Rails, forking and leadership

I decided to let it all out. What a funny coincident because exactly 5 years ago I wrote that I’m leaving Rails for good. I thought I’m gonna leave Ruby too but that didn’t happen and I’m still a very happy Rubyist and because of this I’m really saddened to see what’s been going on the past few days; but HEY, it’s up to us to make something good out of it.

There are a couple of things I want to address and clarify through this post because:

  • There are people who called for a Rails fork
  • There are people who try to convince others (and themselves?) that Rails != DHH/Basecamp

Here’s the thing – both groups of people are…kinda wrong but unfortunately things aren’t so simple. Let me…

Hey fork me, easy as 1-2-3

Hi, we're Arkency 

How to build a read model with Rails Event Store Projection

Recently I faced interesting challenge in one of our customer’s application. Imagine that you take a test after which you get a personalised reports about your skills level. Existing mechanism for that was time and resource consuming. People had to wait for e-mail delivery with PDF-generated report several hours due to several constraints, which I would prefer not to dive into.

The solution was obvious — lets progressively build read model every time someone answers the question. After the test is done, the report will be available instantly in a web ui.

Let’s start with a domain event

module TestExecution
  class AnswerRegistered < ::Event
    attribute :participant_id, Types::Integer
The RubyMine Blog : The Ruby on Rails IDE | JetBrains Blog 

RubyMine 2021.1.1 Is Available

RubyMine 2021.1.1 is now available!

You can update using the Toolbox App or right from inside the IDE. You can also download RubyMine 2021.1.1 from our website.

New features

  • We’ve added the concept of trusted projects.
  • We have reworked Minitest support.

    If you use Minitest in RubyMine, please update your project configuration to use the new functionality. In your Minitest configuration file (/test/test_helper.rb), replace MiniTest::Reporters.use! with Minitest::Reporters.use! unless ENV['RM_INFO'].

    Please refer to our blog post to learn more.

Bug-fixes

You’ll find the following important fixes in this update:

  • Fixed an issue with the search functionality: IDEA-266391.
  • Fixed an issue…
Remote Ruby 

Building iOS apps using Hotwire / Turbo.js with Joe Masilotti

[00:01:59] Jason tells us about WNB.rb, which is a new virtual community for women and non-binary Rubyists to get involved in. 
[00:03:23] Joe tells us all about himself and what he does. 
[00:05:08] We learn how it was in the early days when Joe was just using the Turbolinks version. 
[00:09:20] Joe tells us things he’s built in the past especially when people are trying to convert their app to mobile.
[00:13:48] JavaScript Bridge is talked about, how to use it, and how Joe learned about it.
[00:19:48] Joe explains Progressive Enhancement. [00:22:51] Joe touches on the concept of the Path Configuration and he explains what it does.
[00:29:39] Find out Joe’s thoughts on Authentication.…
With a Twist 

A git branching model for 15 people sharing a single testing environment

My development team collaborates every day with a QA team to ship timely well-tested work. We work on a feature and put it up for testing; if QA passes it, we prepare it for production. Every week, after QAs perform full regression testing, we deploy to production (occasionally, they spot tricky bugs or regressions that we fix or revert).

A typical workflow, but with a caveat: we share a single testing environment (and thus git branch), which complicates preparing releases: either the shared branch contains untested code, or developers wait on QA and on each other to merge after acceptance. We tried for long to solve this from scratch by provisioning more testing environments, so that…

Awesome Ruby Newsletter 

💎 Issue 258 - The Best Ruby HTTP clients for 2021

Ruby Weekly 

Ruby is not Rails

#​550 — April 29, 2021

Read on the Web

Ruby Weekly

The Best Ruby HTTP Clients for 2021? — A ‘dad jokes’-powered roundup of various ways to making HTTP requests (that go beyond the simple URI.open approach) including Faraday, Net::HTTP, and my personal favorite, http.rb.

Sylwia Vargas

(Some of) What's Cooking in Rails 7 — I expect these Rails 7 posts to increase in frequency and we're going to read them all. :-)

Jason Dinsmore

ButterCMS Melts into Your Rails App. #1 Rated Headless CMS — ButterCMS is the #1 rated Headless CMS for Rails. Let your marketing team blog, create landing pages and more…

code.dblock.org | tech blog 

Walking Ethereum Transaction Logs to Find Lost Robbies w/Etherscan API

On July 17, 2018, I spoke at the Christies first ever annual Tech Summit entitled “Exploring Blockchain”, in London. I even got a freebie NFT!

During the event SuperRare partnered with Jason Bailey and enlisted Robbie Barrat, the first artist to ever tokenize on SuperRare. Robbie created “AI Generated Nude Portrait #7” for the event, which he intended as 300 separate frames of a single artwork. Each of the 300 frames was tokenized separately and added to redeemable ETH gift cards with directions for how to claim the 1/1 token.

A small handful of these original NFTs are known to still exist. We’ll call them “Robbies”. On April 5th, 2021, frame 269 sold for 125ETH ($265K).

If you enjoyed…

The RubyMine Blog : The Ruby on Rails IDE | JetBrains Blog 

RubyMine 2020.3.4 Is Available

RubyMine 2020.3.4 is now available!

You can update to it using the Toolbox App, right from inside the IDE, or by downloading RubyMine 2020.3.4 from our website.

New features

  • We’ve added the concept of trusted projects.
  • We have reworked Minitest support.

    If you use Minitest in RubyMine, please update your project configuration to use the new functionality. In your Minitest configuration file (/test/test_helper.rb), replace MiniTest::Reporters.use! with Minitest::Reporters.use! unless ENV['RM_INFO'].

    Please refer to our blog post to learn more.

Bug fixes

You’ll find the following important fixes in this update:

  • Reworked Minitest support resolves a bunch of issues related to running…
Planet Argon Blog 

Software Engineers: In Need of Inspiration?

Software Engineers: In Need of Inspiration?

The Maintainable Software Podcast has interviewed experts all across the software development industry, from CEOs to Project Managers, to Sr. Engineers. Since our launch two years ago, we’ve been able to sit down with some amazing people and learn the ins and outs of software development from their personal experience.

Continue Reading

Hi, we're Arkency 

When in doubt, signal!

When you are writing frontend applications you often need to fetch some data. Sometimes, especially when you’re working with a single-page app, some requests could be cancelled as you would not use the response anywhere, e.g. when your visitor clicks on some link and changes the page during the pending request that would no longer be needed on the next page. If you are using fetch to perform AJAX requests, you can use AbortController to cancel pending requests in such situations.

AbortController and AbortSignal are features available in most modern browsers, there are also some polyfills available for those unfortunates who need to support IE.

Usage

Using AbortController to cancel fetch

All Ruby Podcasts by Devchat.tv 

BONUS: Relationships Matter Most

Charles Max Wood talks about how to build, grow, and benefit from positive relationships within programming. He talks about how he's built genuine positive relationships with hundreds of programmers and how he and others have grown from those relationships. He also explains that you get out of relationships what you put into them. Finally, he goes into how to begin to build relationships by building a system of influence you can use on behalf of the people you want relationships with.

Panel

  • Charles Max Wood

All Ruby Podcasts by Devchat.tv 

Reflecting on Stimulus with Julian Rubisch - RUBY 495

We talk with Julian about a few projects, including Stimulus, Stimulus Reflex, and SPAs and how they fit into our modern tech stacks.

Panel

  • Charles Max Wood
  • John Epperson
  • Luke Stutters

Guest

  • Julian Rubisch

Sponsors

Links

Picks

Peter Zhu 

A Rubyist’s Walk Along the C-side (Part 3): Calling Methods

Calling Ruby methods in C extensions.
GoRails Screencasts 

Setting up Customer Support models with Hotwire

In part 1, we're going to setup our Rails application, our models, and connect Hotwire so we can dig into building ActionMailbox next.
Frank’s blog 

My First Month as a Solo Founder

On the first of april I started my first full-time month as the solo founder of Webindie. I’ll try to build a bootstrapped software-as-a-service product that should get me to ramen profitability in a year. Having previous experience running an agency was a huge help so far. Lots of entrepreneurial jobs such as doing taxes, requesting a business bank account, apply for a business credit card, and registering at the chamber of commerce were at least vaguely familiar to me. The development and hosting side of Webindie shouldn’t be a problem either, as at my previous position I’ve been developing and hosting Ruby on Rails web applications for 10+ years.

So didn’t I experience any challenges in…

Ruby on Rails Podcast 

368: Inclusivity and Partner Support with Tay DeHerrera

Tay DeHerrera is a Backend Software Engineer at TextUs. Tay and Brittany discuss getting involved in other initiatives at work and the importance of supporting (and sometimes humoring) a significant other who also writes software.

Links for this episode:

Brought to you by:

Raygun

Save time, money, and sanity by visiting Raygun.com/ruby and join thousands of software teams who use Raygun every day to ship better quality code, faster. It takes just minutes to set up and starts…

Ruby Magic by AppSignal 

Linting Ruby Code

Linting is the process of statically analyzing code in search of potential problems.

What constitutes a problem, in this case, can vary across programming languages, or even across projects within the same language. I would put these problems under a few different categories:

  • Programmatic
  • Security
  • Stylistic
  • Performance

Let’s take a look at a few examples of each.

Stylistic Problems

There’s no objectively right way of styling code, as it’s all about the reader’s preference. The key is consistency though. Common points of debate include:

  1. double-quotes vs single-quotes
  2. tabs vs space
  3. maximum line length
  4. indentation of multiline calls, as shown below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#…
The RubyMine Blog : The Ruby on Rails IDE | JetBrains Blog 

Improved Minitest Support – Action Required

We have updated Minitest support in RubyMine 2020.3.4 and 2021.1.1.

The new approach resolves the issues that occasionally occurred while running Minitest tests, such as memory leaks or irrelevant test states, and makes the overall functionality more stable.

Previously, RubyMine used the minitest-reporters gem, which is no longer used in the reworked Minitest support. To avoid conflicts with the new implementation, this gem should not be used to run tests in RubyMine.

If you use Minitest, please update your project as follows. In your Minitest configuration file (/test/test_helper.rb), replace MiniTest::Reporters.use! with Minitest::Reporters.use! unless ENV['RM_INFO'].

Should you encounter…

Hi, we're Arkency 

Decorate your runner session like a pro

Paweł described some tricks you could use to tune-up your Rails console. I want to tell you about the runner method you can use to enhance your runner sessions.

Decorating runner sessions is a little bit less convenient as we don’t have a module like Rails::ConsoleMethods that is included when runner session is started. So adding some methods available for runner scripts is not that easy. However you can still add some code that will be executed at the start and the end of your runner sessions.

For example you can send some notifications so you don’t need to look at the terminal to check if the script evaluation has been finished. You can also measure time or set some Rails Event Store

Greater Than Code 

232: Outside The Charmed Circle with Tamsin Davis-Langley

01:17 - Tamsin’s Superpower: Recognizing Songs Within Seconds

05:08 - Outside the Charmed Circle (Tamsin’s book about gender, sexuality, and spirituality)

09:09 - Consent in the Mentor/Mentee Relationship (Master/Apprentice)

  • The Universal Attribution Fallacy
  • Access
  • Power Dynamics
  • Conflicts of Interest
  • The Word “Politics” - how we negotiate power between groups of greater than one

16:57 - Using Certain Phrases (i.e. “Identity Politics,” “Cancel Culture”) and Divisiveness

23:46 - What Is A Person? Individuality & Personhood

Hi, we're Arkency 

Rails console trick I had no idea about

Rails console trick I had no idea about

Tweaking .irbrc to make interactive console comfortable is a highly-rewarding activity. You gets instant boost of productivity and there are less frustrations. There were numerous posts and tips featured in Ruby Weekly on this topic recently.

I’ve been making my .irbrc more useful too. The harder part was always distributing those changes to remote servers. For example to have those goodies available in Heroku console. And not only for me. There are multiple ways to achieve that, duh. The one that stick though was close to the app code:

# script/likeasir.rb

# Nice things to have when entering production console
# load 'script/likeasir.rb'

def event…
code.dblock.org | tech blog 

Walking Etherium Transaction Logs to Find Lost Robbies w/Etherscan API

On July 17, 2018, I spoke at the Christies first ever annual Tech Summit entitled “Exploring Blockchain”, in London. I even got a freebie NFT!

During the event SuperRare partnered with Jason Bailey and enlisted Robbie Barrat, the first artist to ever tokenize on SuperRare. Robbie created “AI Generated Nude Portrait #7” for the event, which he intended as 300 separate frames of a single artwork. Each of the 300 frames was tokenized separately and added to redeemable ETH gift cards with directions for how to claim the 1/1 token.

A small handful of these original NFTs are known to still exist. We’ll call them “Robbies”. On April 5th, 2021, frame 269 sold for 125ETH ($265K).

If you enjoyed…

Hi, we're Arkency 

How to balance the public APIs of an open-source library — practical examples from RailsEventStore

How to balance the public APIs of an open-source library — practical examples from RailsEventStore

On twitter, Krzysztof asked an interesting question: what are our thoughts on carving a well-balanced API for an open-source library that RailsEventStore is:

This post is a whirlwind tour on RailsEventStore interfaces, components and decisions behind them.

In case you’re still wondering:

Rails Event Store is a library for publishing, consuming, storing and retrieving events. It’s your best companion for going with an Event-Driven…

BigBinary Blog 

Handling environment specific configurations in React Native

Many modern-day applications now go through different stages of the productcycle such as development, staging, production etc.

Having different environment variables for each environment will make it a loteasier to manage any application. This article is intended to share one solutionto address this problem in React Native. We will be using a library calledreact-native-config for thispurpose; you can also tryreact-native-dotenv.

We will be focusing on having three different bundles containing configurationfiles for development, staging and production environments.

Installing react-native-config

Install the package:

yarn add react-native-config

For iOS also run pod install after package is…

Setup…

Saeloun Blog 

Rails 7 allows constructors on has_one :through associations

When we declare a belongs_to association, the declaring class automatically gains build_association and create_association methods.

For example, given the declaration:

class Book < ApplicationRecord
  belongs_to :author
end

Each instance of the Book model will have build_author and create_author methods.

Now let’s consider the following models.

# app/models/supplier.rb
class Supplier < ApplicationRecord
  has_one :account
  has_one :account_history, through: :account
end
# app/models/account.rb
class Account < ApplicationRecord
  belongs_to :supplier
  has_one :account_history
end
# app/models/account_history.rb
class AccountHistory < ApplicationRecord
  belongs_to :account
end

To…

BigBinary Blog 

Rails 7 adds Enumerable#sole

Rails 7 introduces the Enumerable#sole method, which can be used to find and assertthe presence of exactly one element in the enumerable.

The Enumerable#sole method is an add-on forActiveRecord::FinderMethods#soleand#find_sole_bymethods, which were recently added in Rails 6.1. Please checkour blogfor more details on it.

=> list = ["Sole Element"]=> list.sole=> "Sole Element"=> hash = { foo: "bar" }=> hash.sole=> [:foo, "bar"]

The Enumerable#sole method raises Enumerable::SoleItemExpectedError error ifthe enumerable is empty or contains multiple elements. When the sole element isnil, it will be returned as result.

=> list = [nil]=> list.sole=> nil=> list = []=> list.sole=>…
Vladimir Makarov – Red Hat Developer 

The MIR C interpreter and Just-in-Time (JIT) compiler

For the past two years I’ve worked on a project implementing a universal lightweight Just-in-Time (JIT) compiler known as MIR. The cornerstone of the project is a machine-independent medium-level intermediate representation (MIR).

A big part of the project consists of code that compiles C source code into MIR. Because MIR can be interpreted and just-in-timed, I easily extended this C-to-MIR compiler into a C interpreter and JIT compiler.

I have previously written about other parts of the MIR project (see MIR: A lightweight JIT compiler project, but I never wrote in detail about the C-to-MIR compiler, C interpreter, or JIT. In this article, I would like to correct these omissions.

Motivation…

The Bike Shed 

290: Can You See My Secrets?

On this week's episode, Chris and Steph discuss testing webhooks, the challenges in replicating third-party data, and troubleshooting unexpected side effects. They also respond to a listener question about secrets management, touring popular solutions and discussing the trade-offs.


This episode is brought to you by ScoutAPM. Give Scout a try for free today and Scout will donate $5 to the open source project of your choice when you deploy


Support The Bike Shed

Rails with Jason 

093 - Ruby Garbage Collection with Jemma Issroff

In this episode I talk with Jemma Issroff about how garbage collection in Ruby works. Concepts discussed include the Ruby heap and tri-color mark-and-sweep.

Links:

Honeybadger Developer Blog 

Understanding Insertion Sort in Ruby

Note: This is part 4 in a series looking at implementing various sorting algorithms with Ruby. Part 1 explored bubble sort, part 2 explored selection sort, and part 3 explored merge sort.

As we continue to explore different methodologies for sorting data, we turn to insertion sort. There are a number of reasons to like insertion sort! First, insertion sort is stable, which means that it does not change the relative order of elements with equal keys. It's also an in-place algorithm, meaning that it does not create a new array to store the sorted elements. Finally, insertion sort is a pretty simple algorithm to implement, as you'll soon see!

Why Care

It's difficult to avoid sounding like…