Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
avdi.codes 

SIGAVDI #92: Breakfast Smoothie Edition

Hello friends,

It’s been a hectic couple of weeks. I’ve been doing a lot of RSpec test suite maintenance. I have lots of Big Opinions about how to do spec suites well, but the truth is the combination of Ruby, Rails, RSpec and FactoryBot furnish so many opportunities to grow thickets of impenetrable test code that I can’t fault anyone who finds themselves with a flaky, slow-running, hard-to-update mess on their hands. Test suites are best when they are boring, and these tools offer many, many opportunities to make them… interesting.

Ruby Yagi 🐐 

How to run tests in parallel in Github Actions

How to run tests in parallel in Github Actions

The company I work for has recently switched to Github Actions for CI, as they offer 2000 minutes per month which is quite adequate for our volume. We have been running tests in parallel (2 instances) on the previous CI to save time, and we wanted to do the same on Github Actions.

Github Actions provides strategy matrix which lets you run tests in parallel, with different configuration for each matrix.

For example with a matrix strategy below :

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        ruby:
          - '2.5.x'
          - '2.6.x'
          - '2.7.x'
        activerecord:
          - '5.0'

It will run 9 tests in parallel, 3 versions of Ruby x 3 versions of…

Saeloun Blog 

Rails 6.1.1 allows `where` to reference associations via joined table alias names.

Rails 6.1 has added a feature wherein we can specify an alias name of the model in the where clause.

Let’s say we have an Employee model as below:

class Employee < ActiveRecord::Base
  has_many :subordinates, class_name: "Employee", foreign_key: :manager_id
  belongs_to :manager, class_name: "Employee"
end

Employees without a manager will have manager_id as nil.

Before

Let’s take a scenario where we need to fetch all employees whose manager name is Sam.

There can be two ways to fetch this data.

Employee.find_by(name: "Sam").subordinates
SELECT "employees".* FROM "employees" WHERE "employees"."name" = $1 LIMIT $2  [["name", "Sam"], ["LIMIT", 1]]
SELECT "employees".* FROM "employees" W…
Martian Chronicles, Evil Martians’ team blog 

Social background: Martians behind eBay Social's tech

Authors: Maxim Kushner, Account Manager at Evil Martians and Olga Rusakova, Writer at Evil Martians

eBay, a global marketplace leader, turned 25 in 2020. For over a quarter of that era, Martians have been cooperating with one of the world’s leading brands and shipping two eBay spin-offs—eBaymag, a B2B service for sellers, and eBay Social, an official cashback service in Russia.

eBay Social has graduated out of beta, serving over 150,000 active users who purchased more than a million products and received over 58 million RUB (almost $100,000) of cashback. The attained metrics give us a chance to reveal what the Martians have done to achieve these results.

The Martians’ mission is to…

Andy Croll 

Memoize Expensive Code

Memoization is a performance optimization where the result of a slow or non-performant piece of code is temporarily stored, and when the expensive code is called again, the stored value is returned.

Instead of …

…repeating potentially expensive calculations:

class OldTimeySweetShop
  def average_sweets_per_jar
    sweet_count / glass_jars.count
  end

  def sweet_count
    glass_jars.sum do |jar|
      jar.count_each_sweet_by_hand
    end
  end
end

Instead…

…use the ||= (or equals) operator to store expensive computations in an instance variable.

class OldTimeySweetShop
  def average_sweets_per_jar
    sweet_count / glass_jars.count
  end

  def sweet_count
    @sweet_count ||= glass…
Saeloun Blog 

Running a Rails Consultancy- experiments on profit sharing

We recently announced our first yearly profit share for our employees. I have talked about it a couple of times in the past, as well as list it as one of the Employment benefits. This post tries to summarize a bit about how it went for us this year, as well as some of the discussions with our team members during this process.

Why?- Ownership

Last year I had posted, how the profit-sharing model helps us bring some ownership to our employees.

Some of them were:

  • An increased sense of ownership.
  • Brings stocks/profits philosophy from Product companies to a Consulting business.
  • More relatable career growth.
  • The company’s success is your success!

These were primarily some of…

Janko’s Blog 

Interesting throw/catch behaviour in Ruby

When I was working on integrating Rodauth with OmniAuth authentication, I noticed an error warning after upgrading to Rails 6.1, when Rodauth was redirecting inside a Rails controller action:

class RodauthController < ApplicationController
  def omniauth
    # ...
    rodauth.login("omniauth") # logs the session in and redirects
  end
end
Could not log "process_action.action_controller" event.
/path/to/actionpack-6.1.1/lib/action_controller/log_subscriber.rb:26:in `block in process_action': undefined method `first' for nil:NilClass (NoMethodError)

Since I want the integration between Rodauth and Rails to be as smooth as possible, I decided to investigate.

Diving in

Let’s see the Actio…

Riding Rails 

Defaults to “main” branch name, new webpacker guide and improved strict loading

Hi, Wojtek here with the summary of changes from the last days.

Renamed master branch to main in the Rails repository

As mentioned by DHH and performed by Rafael França the default branch for most of the Rails git repositories is now called “main”.

Webpacker added to edge guides

The detailed guide how to use webpack build system with Rails via webpacker gem. You can read it on edge guides.

Opting out of strict loading on a per-record base

This is useful when strict loading is enabled application wide or on the model level.

Improved strict loading violation error message

This change updates the error message to include both the class and the association name which makes it clear what…

Josh Software 

Easy pagination with Android Paging Library

Android Jetpack introduced a lot of libraries which are driving developers to enhance architecture and reduce boilerplate code, one of them is the Android Paging library which makes it easy for you to add Pagination in your project. If you are building an app which loads large data from a server or the database and … Continue reading Easy pagination with Android Paging Library
John Nunemaker 

Rails: Postgres Partial Indexing

While working on a new Box Out feature, I needed to query for graphics that have been shared on social media.

I had a graphics table with a tweet_id column. I wanted to query for graphics that have been shared on twitter (aka tweet_id IS NOT NULL).  

The table is in the hundreds of thousands of rows, so I wanted to index tweet_id to help the query along. I was going to a plain old add_index. But then I remembered that you can do partial indexes.

I knew that this was possible with Postgres. And I've used partial indexes in the past. What I didn't know is that you do this through Rails migrations without dropping down to execute and vanilla SQL (not that there is anything inheritantly bad about…

where

A few googles…

Running with Ruby 

How requiring a gem can mess up your already running application

Introduction

Ruby’s dynamic nature is both its advantage and disadvantage. Being able to reopen system classes during runtime, while useful, can also lead to unexpected behaviors. This article presents one such case: how just requiring a gem can mess things up in a completely different area of the application.

The bizzare error

Recently, after connecting the Diffend monitor into one of my systems, it started reporting a bizarre error:

uninitialized constant Whenever

whenever-1.0.0/lib/whenever/numeric.rb:3:in `respond_to?'
lib/ruby/2.7.0/bundler/settings.rb:368:in `=='
lib/ruby/2.7.0/bundler/settings.rb:368:in `=='
lib/ruby/2.7.0/bundler/settings.rb:368:in…
Julia Evans 

Firecracker: start a VM in less than a second

Hello! I spent this whole past week figuring out how to use Firecracker and I really like it so far.

Initially when I read about Firecracker being released, I thought it was just a tool for cloud providers to use – I knew that AWS Fargate and https://fly.io used it, but I didn’t think that it was something that I could directly use myself.

But it turns out that Firecracker is relatively straightforward to use (or at least as straightforward as anything else that’s for running VMs), the documentation and examples are pretty clear, you definitely don’t need to be a cloud provider to use it, and as advertised, it starts VMs really fast!

So I wanted to write about using Firecracker from a…

Code with Jason 

A scientific, systematic methodology for solving any programming problem

In order to fix any problem, you need to know two things:

  1. What exactly is wrong
  2. How to fix it

The beautiful thing is that if you have the right answers for both the two items above, you’re guaranteed to fix the problem. If your fix doesn’t work, then it necessarily means you were wrong about either #1 or #2.

The fastest way to solve any problem is to focus first on finding out what’s wrong, with reasonable certainty, before you move onto the step of trying to fix the problem. “Diagnose before you prescribe.”

Why it’s faster to separate the diagnosis from the fix

There are two reasons why I think it’s faster to separate the diagnosis from the fix than to mix them up. The first is that if…

Emmanuel Hayford 

3 Practical Uses of Ruby’s `method_missing` You Should Know.

Ruby’s dynamism is awe-inspiring. One of the methods that contribute to this is method_missing. method_missing is defined in BasicObject. method_missing allows us to:

Let’s discuss the practical uses of this method.

What is Ruby’s method_missing?

We define methods inside classes. Ruby traverses a method lookup path when an object calls a method, starting from the object’s class and up the object’s class’s ancestor chain to reach the method. If the method the object calls is available in the lookup path, Ruby calls it. On some occasions, the method isn’t present in the ancestor chain.

All method lookups that fail end up reaching a method…

zverok with ruby 

Rebuilding the spellchecker, pt.4: Introduction to suggest algorithm

This is the fourth part of the “Rebuilding the spellchecker” series, dedicated to explaining how the world’s most popular spellchecker Hunspell works.

Today’s topic is suggest!

Quick recap:

  1. In the first part, I’ve described what Hunspell is; and why I decided to rewrite it in Python. It is an explanatory rewrite dedicated to uncovering the knowledge behind the Hunspell by “translating” it into a high-level language, with a lot of comments.
  2. In the second part, I’ve covered the basics of the lookup (word correctness check through the dictionary) algorithm, including affix compression.
  3. In the third part, the rest of the lookup is explained: compounding, word breaking, and text case.
Awesome Ruby Newsletter 

💎 Issue 244 - How Fast is Ruby 3 on Rails?

Rémi Mercier 

Always serving someone

It’s Monday morning, and you open up a handful of files. You want to get a sense of that piece of the codebase you’re about to work on. You’re soon finding yourself surrounded by circumvoluted code, abstractions pilling on each other, classes filled to the brim. You end up spending your day trying to figure things out.

This is a lousy Monday.

What happened then? Well, the person/people who wrote the code forgot they’re delivering a service. Maybe it was you.

I mean, it’s easy to tell yourself that you don’t give a hoot about your users when you’re knee-deep into SQL queries. You’re not here to provide a great service to your users. You’re here to fetch data, pass it around between…

Honeybadger Developer Blog 

honeybadger.js is now universal

For years, Honeybadger has supported client-side JavaScript and Node.js via two separate NPM packages: honeybadger-js (client-side) and honeybadger (Node.js). Today, we're excited to release a new universal package for JavaScript: @honeybadger-io/js.

The following packages are deprecated moving forward:

Use @honeybadger-io/js instead.

Why make this change?

Combining our JavaScript packages means we can share the same core client code while integrating deeply with each environment. The result is less duplication, better consistency, and a more straightforward experience for universal/isomorphic apps that run in multiple environments via Server-side Rendering…

Ruby Weekly 

How fast is Ruby 3 on Rails?

#536 — January 21, 2021

Read on the Web

💡 One of the most popular recurring features we've added to our sister Postgres Weekly newsletter has been a 'tip of the week.' We've been looking to begin this in Ruby Weekly too, and thanks to the hard work of Jemma Issroff we've got out first one this week. Don't miss it at the end of this issue :-)
__
Peter Cooper, editor

Ruby Weekly

How Fast is Ruby 3 on Rails? — The king of running Ruby and Rails benchmarks is back with a look at how Ruby 3 handles Rails from a performance point of view. Spoilers: The final release of Ruby 3.0 is more stable under…

Honeybadger Developer Blog 

How ActiveRecord Uses Caching To Avoid Unnecessary Trips To The Database

A general way to describe caching is storing the result of some code so that we can quickly retrieve it later. In some cases, this means storing a computed value to avoid needing to recompute it later. However, we can also cache data by simply keeping it in memory, without performing any computations, to avoid having to read from a hard drive or perform a network request.

This latter form is particularly relevant for ActiveRecord, where the database often runs on a separate server. Thus, all requests incur network-traffic overhead, not to mention the load placed on the database server when the query is performed again.

Fortunately, for Rails developers, ActiveRecord itself already handles…

The Rails Tech Debt Blog 

How Fast is Ruby 3 on Rails?

If you've been following me awhile, you know that I was hired by AppFolio years ago to measure Ruby 3's performance, especially on Rails. This has been a long trip. And that very first project is finally over: Ruby 3 exists and I can check its final, released Rails performance.

If you have been following along, the numbers in this post won't surprise you. But it's important to do the final measurement. If you haven't been following, this will bring you up to date.

What Am I Measuring?

In concept, I'm measuring "how fast is Ruby 3 versus Ruby 2.6 or 2.7 for a typical real-world Rails workload?"

"Typical real-world workload" is a vague, hand-wavy concept. But there are a lot of…

Ruby on Rails Podcast 

354: Rails Committer Heavy Hitter with Rafael França

Rafael França is a Principal Engineer at Shopify. He has been a member of the Rails Core team since 2012 and is the contributor with the most commits to the framework. He and Brittany discuss his confident release of Rails 6.1 and some hints for Rails 7.

Links for this episode:

Brought to you by:

Scout APM

Give Scout APM a try for free today and Scout will donate $5 to the open source project of your choice when you deploy.

Lin…

Emmanuel Hayford 

Dedicating 2021 To Writing More And Reading Less.

I don’t do New Year’s Resolutions”. I don’t set any resolutions on the 1st of January partly because I like to treat all days equally. The reason behind this is, I feel restrained when I have to celebrate something on a day set by God knows who.

It’s January 2021 now, and I choose to write more this year. I’ve noticed I consume a lot of information but do very little with it. If reading books were like alcohol consumption, I’d be in rehab.

I’ve thought carefully about how much information I gobble up, and I think I’ve had enough of reading. I don’t want to be a Tsundoku master. I want to write.

I am self-diagnosed with infobesity. I read about tech stacks all over the place. At one point…

Greater Than Code 

218: Building Bridges with Isa Herico-Velasco

02:12 - Isa’s Superpower: Being a Bridge

08:56 - Community Learning

  • Asynchronous Communication
  • Cultivating a Leadership Pipeline
  • Transparency
  • “Many hands make light work.”

19:16 - Pivoting From Rock’n’Roll to Software Engineering: Software + Music

  • Gigwell: Talent Booking
  • Everything Relates to Tech Somehow

27:57 - Grappling with Impostor Syndrome

Reflections:

Damien: Community over architecture.

Casey: Community and mentorship.

Isa: Talking to other engineers re: non-code + community and sustainability.

Laurie: Finding new ways to collaborate in a remote/pandemic world.

This episode was brought to you by @th…

Kir Shatrov 

Five years at Shopify

This week I have celebrated a five year anniversary working at Shopify, one of the world’s biggest ecommerce platforms. It’s been an incredible journey and I’d like to use this anniversary as a chance to reflect about my time at Shopify.

Where I was coming from

Prior to Shopify I was at Evil Martians, a product development consultancy. That’s probably the best smaller size company that I could have ever worked at. Martian’s culture has allowed me to work on open source, speak at conferences like RailsConf, and work with high profile clients from Y Combinator and the Fortune 500 list.

As much as I enjoyed staying there, at certain point I’ve been curious to explore the next challenge.…

BigBinary Blog 

Authorization in REST vs Postgraphile

Postgraphileis a great tool for making instant GraphQL from a PostgreSQL database.When I started working with Postgraphile, its authorization part felt a bit different compared to the REST based backends which I had worked with before.Here I will share some differences that I noted.

First, let's see Authentication vs Authorization.

Authentication is determining whether a user is logged in or not.Authorization is then deciding what the users has permission to do or see.

Comparing the implementation of a blog application using Postgraphile vs REST

Suppose we have to build a blog application with the below schema.

event delegation

Features of the blog application.

  • Display published blogs with is_published = true to…

  • Display unpublished

AkitaOnRails.com 

[Akitando] #89 - Introdução a Videogames e Emuladores

DESCRIÇÃO

Finalmente vou contar sobre um dos assuntos que eu mais gosto: videogames e emuladores. E aproveitar os episódios que eu vim fazendo sobre Introdução a Computadores pra adicionar mais alguns conhecimentos interessantes pra quem é programador entender como essas coisas funcionam.

ERRATA: eu falo que PPSSPP emula PS Vita mas na verdade é o PSP.

Links:

  • Understanding the ELF File Format (https://linuxhint.com/understanding_elf_file_format/)
  • Super Nintendo Architecture (https://www.copetti.org/projects/consoles/super-nintendo/)
  • Mega Drive Architecture (https://www.copetti.org/projects/consoles/mega-drive-genesis/)
  • CPU comparison: SNES vs. Genesis vs. TG16…
BigBinary Blog 

Rails 6.1 allows per environment configuration support for Active Storage

Rails 6.1 allows environment-specific configuration filesto set up Active Storage.

In development, the config/storage/development.yml filewill take precedence over the config/storage.yml file.Similarly, in production, the config/storage/production.yml filewill take precedence.

If an environment-specific configuration is not present,Rails will fall back to the configuration declared in config/storage.yml.

Why was it needed?

Before Rails 6.1, all storage services were defined in one file,each environment could set its preferred service in config.active_storage.service,and that service would be used for all attachments.

Now we can override the default application-wide storage servicefor any…

AkitaOnRails.com 

[Akitando] #90 - O que os Cursos NÃO te Ensinam sobre Mercados

DESCRIÇÃO

Esta é a edição da palestra que dei no evento #DoWhile da Rocketseat no dia 15/12/2020. Ela serve como um resumo de vários assuntos importantes do canal então aproveito pra deixar como introdução pra quem está chegando agora. Durante o vídeo vou mostrando as thumbnails dos diversos videos onde entro em detalhes sobre cada assunto.

E sendo o 1o vídeo do ano, deixo meu FELIZ 2021!! 🥳🎊🎉

ERRATA: no tweet do cara investindo e calculando juros errados, dependendo de como interpretar o texto dele (e aqui fica pior, porque além de tudo ele tem dificuldade de explicar) fica ainda pior a matemática. Se considerar que ele achou que dividindo o dinheiro dele, digamos 70 mil reais, em 7…

All Ruby Podcasts by Devchat.tv 

RUBY 484: Bootcamps: Bad or Badass

We discuss the value of bootcamps and whether new developers should consider them. We also touch a little bit on related topics like interviewing.

Panel

  • Charles Wood
  • John Epperson
  • Luke Stutters

Sponsors

Links

Picks

RubyGems Blog 

3.2.6 Released

RubyGems 3.2.6 includes enhancements and bug fixes.

To update to the latest RubyGems you can run:

gem update --system

To install RubyGems by hand see the Download RubyGems page.

## Enhancements:

  • Fix Gem::Platform#inspect showing duplicate information. Pull request #4276 by deivid-rodriguez

## Bug fixes:

  • Swallow any system call error in ensure_gem_subdirs to support jruby embedded paths. Pull request #4291 by kares
  • Restore accepting custom make command with extra options as the make env variable. Pull request #4271 by terceiro

SHA256 Checksums:

  • rubygems-3.2.6.tgz
    7ec722c811a36961dcf048b83ed135f71e617ea105f1d8772299958351059866
  • rubygems-3.2.6.zip
    2164a6f2eac20bab5ec0c…
Remote Ruby 

Hotwire, Rails NEXT, and the DHH Stack™ with David Heinemeier Hansson

[00:00:34] DHH jumps right into telling us what the response has been to Hotwire and how Basecamp has felt about the response.
[00:04:02] DHH talks about a book they published in 2013 and mentions to “wait for the pendulum to come your way,” and how this relates to Hotwire. He also talks about Turbo.
[00:08:06] Since Hotwire, the whole package, is a separate gem you bring in, Jason asks DHH if long term, that will continue to be the case or if that will ship with Rails. [00:15:39] Rails 7 is brought up by DHH and how there is work to be done.  [00:19:39] Jason mentions to DHH there are a lot of questions about Strada and Mobile, Mobile, Mobile and asks him how the missing piece “air…
Rails with Jason 

080 - Organizing Rails Code Outside of Active Record with Dave Copeland, Author of Sustainable Rails

In this episode I talk with Dave Copeland, author of Sustainable Web Development with Ruby on Rails, about organizing Rails code. Dave and I discuss why although many Rails developers are used to it, putting code in Active Record models isn't always the best move. We also share the various tactics we prefer to use in order to keep Rails code organized.

Links:

BigBinary Blog 

Rails 6.1 adds support for belongs_to to has_many inversing

Before Rails 6.1,we could only traverse the object chainin one direction - from has_many to belongs_to.Now we can traverse the chain bi-directionally.

The inverse_of option, both in belongs_to and has_many isused to specify the name of the inverse association.

Let's see an example.

class Author < ApplicationRecord  has_many :books, inverse_of: :authorendclass Book < ApplicationRecord  belongs_to :author, inverse_of: :booksend

Before Rails 6.1

has_many to belongs_to inversing

irb(main):001:0> author = Author.newirb(main):002:0> book = author.books.buildirb(main):003:0> author == book.author=> true

In the above code,first we created the author and thena book instance through the has_many association.

BigBinary Blog 

Sort query data on associated table in PostGraphile

PostGraphileprovides sorting on all columns of a tablein a GraqhQL query by default with orderBy argument.

Although, sorting based onassociated tables columnsor adding a custom sortcan be acheived via plugins.In this blog we will explore two such plugins.

Using pg-order-by-related plugin

pg-order-by-relatedplugin allows us to sort query resultbased on associated table's columns.It does that by adding enums for allassociated table's columns.Here's what we need to do to use this plugin.

Installation

npm i @graphile-contrib/pg-order-by-related

Adding the plugin

const express = require("express");const { postgraphile } = require("postgraphile");const PgOrderByRelatedPlugin =…
The Bike Shed 

277: Making Communication Easier

In this week's episode, Steph and Chris discuss some of their methods for helping out reviewers of their pull requests and keeping code review moving along smoothly. They also discus the shift to async communication and the tools, processes, and workflows that come with a shift to async. Does standup still have a place in an async world? Tune in to find out.


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


Become a Sponsor of The Bike Shed!

Sponsored By:

Giant Robots Smashing Into Other Giant Robots 

Testing Objects with a Functional Mindset

When unit testing our Object-Oriented (OO) code, some methods are easy to test while others are hard. Functional programming gives us a mental model to help understand why: pure functions and side-effects.

Easy tests

Some methods are super easy to test. You set up an object, call the method, and expect a given result. This sort of test makes TDD a breeze.

it "uppercases the string" do
  expect("abc".upcase).to eq "ABC"
end

Have you ever wondered why these methods are so easy to test? It’s because all the inputs and outputs are above board. There are no implicit inputs like the system clock. Functional programmers might call such a method a pure function.

Because we have…

Posts 

An Unusual Performance Optimization

I regularly run the HexaPDF benchmarks to make sure that HexaPDF gets faster and not slower. One of the benchmarks, the “raw_text” benchmark, always had me wondering why using TrueType fonts was visibly slower. So I decided to investigate.

The Odd Benchmark Result

The “raw_text” benchmarks tests the performance of close-to-metal text output. This is important because it is the limiting factor when creating PDF files, especially big PDF files, with much text content.

What the benchmark does is

  • reading a file line by line,
  • putting each line on a page, without line wrapping and with manual cursor positioning,
  • and creating new pages as necessary.

Here is the main part of the…

The Rails Tech Debt Blog 

The Rails Upgrade Series

Welcome to our series of Rails upgrade miniguides. Here you'll find links to all of the relevant posts to help with an upgrade.

First, if you or your boss are unsure whether an upgrade is a good idea then we have a pair of articles covering the technical and business reasons:

Laying the groundwork

Before jumping into updating gems and other actions, it is important to assess your codebase and lay the groundwork for your upgrade.

We would recommend that you assess your codebase before making changes, both to understand the work required and to find potential…

Ruby Together News 

December 2020 Monthly Update

Hello! Welcome to the monthly update. During December, our work was supported by Zendesk, DigitalOcean, Bleacher Report, and many others.

ruby together news

In December, Ruby Together was supported by 41 different companies, including Ruby member Zendesk and Sapphire member Stripe. 2 companies joined as new members.

On top of those companies, 2 new developers signed up as members, including Sinan Taifour and Nick Willever. In total, we were supported by 105 developer members. Thanks to all of our members for making everything that we do possible. <3

rubygems & bundler news

In December, we finally released Bundler 2.2 and RubyGems 3.2. 🎉 On the Bundler side, this minor release provides…

Hi, we're Arkency 

The Goodies in Rails Event Store 2.x

The Goodies in Rails Event Store 2.x

But… what is Rails Event Store and why would I use it? It’s a Ruby library to publish, consume and store events in your Rails application. Events are an architectural pattern that helps you decouple your code, record what’s happening inside your app, avoid the callback hell and many other kinds of hells. Most often, when you try this pattern, there’s no going back.

We’ve released 2.0.0, 2.0.1, 2.1.0. High fives for Paweł, Mirek and Rafał for all the hard work. Some of the goodies inside:

  • Significantly reduced storage (no explicit “all” stream)
  • Filtering events by timestamp
  • Bi-temporal event sourcing support
  • Multiple database support
  • Listing event…

Read…

Rémi Mercier 

Debugging with pry-byebug: moving in the stack frame

It is a truth universally acknowledged that a single developer in possession of a good codebase must be in want of a bug-free application 1.

Alas, debugging never ends. The more you learn, the more debugging becomes complex.

I think it is high time we dive deeper into pry-byebug. Are you new to pry-byebug? Go and check the beginners introduction to debugging your code first.

Here our menu du jour: moving in the stack frame, adding breakpoints on the fly, and some handy shortcuts (because who loves to write continue continually).

Step into the stack frame: step

I discovered step only recently. One easy way to understand step is to explain it in contrast to next.

next executes the next…

Saeloun Blog 

Rails form_with now defaults to non-remote forms

Veteran users of Rails would expect form_with helpers to return an HTML response, just like all the previous form helpers. However, the default option was now switched to an AJAX response.

With the latest change, it is often confusing for beginners to render out JS responses from the get-go. Fortunately with a recent PR to Rails, it has now been reverted back to rendering default HTML responses.

Before

Previously, form_with would generate a remote form by default.

<%= form_with url: tags_url do |f| %>
  <%= f.text_field :name %>
  <%= f.submit %>
<% end >

This would submit the form as an AJAX request. It is possible to change it by using the local option. Setting local to true would…

Giant Robots Smashing Into Other Giant Robots 

Type systems and checking in Elixir and Ruby

I must admit – when it comes to programming languages, I have a type: robust type systems!

Ever since learning Elm, I’ve fallen in love with programming with a expressive type system. Since I work in other languages as well which are dynamically typed, I find myself yearning for a more robust type system and the guarantees of a static type checker. So I started exploring options for adding types to some of the languages in which I work most frequently, Ruby and Elixir.

Robust type systems are also becoming increasingly popular – it’s not just me who loves them! Type systems and checking eliminates a whole genre of errors – runtime errors – and it does more than that too: it offers a means…

Jemma Issroff 

Bruins Forwards Time on Ice 1/14 vs 1/16

#viz114 { width:100%; height: 900px; border: 1px solid gray; } #viz116 { width:100%; height: 900px; border: 1px solid gray; }

I was pretty confused about the lines in yesterday’s Bruins game against the Devils. So, modeled off of this blog post about shared time on ice of the entire NHL through the 2019-2020 season, I made some visualizations of the Bruins forwards’ shared time on ice in the last two games.

Interpreting the visualizations

The visualizations are interactive, you can click around and drag the players around!

  • Each circle represents a player
  • The size of the circle is proportional to total time on ice
Ruby Yagi 🐐 

Devise only allow one session per user at the same time

Sometimes for security purpose, or you just dont want users to share their accounts, it is useful to implement a check to ensure that only one login (session) is allowed per user at the same time.

To check if there is only one login, we will need a column to store information of the current login information. We can use a string column to store a token, and this token will be randomly generated each time the user is logged in, and then we compare if the current session’s login token is equal to this token.

Assuming your users info are stored in the users table (you can change to other name for the command below), create a “current_login_token” column for the table :

rails g migration…
Karol Galanciak - Distributed Systems Architect and Ruby on Rails expert 

Kafka for Rubyists Mini Course: Advanced Kafka

This is the third part of the Kafka For Rubyists mini course. If you are interested in other parts of the course, please check them out here.

2. Advanced Kafka

Remote Ruby 

Talkin' Puma and the Rails Performance Workshop with Nate Berkopec

[00:01:20] Nate tells us a little bit about himself, what he does, and a book he wrote. 
[00:02:18] Nate talks about the Rails Performance workshop he released a month ago. [00:06:02] Jason asks Nate if he has any plans to go back into the in-person training or if he will keep the current format if it’s showing more advantages. [00:08:03] If you are interested in learning more about performance, Nate shares advice what you should do.
[00:09:37] Jason announces that today we are basking in the release of Hotwire, and he’s curious from a performance perspective if there are any downsides or any performance benefits to doing HTML over the wire.
[00:19:37] Chris asks Nate to talk about…
Code with Jason 

When to use Factory Bot’s traits versus nested factories

When I wrote about nested factories in Factory Bot, I got a couple of questions to the effect of “why wouldn’t you use traits for that?”

In responses to these questions, I’ll lay out my method for deciding when to use traits versus nested factories.

“Is” versus “has”

My method is pretty simple: If the factory I’m considering has something, I use a trait. If the factory is something, I use a nested factory. Let’s look at a concrete example.

“Has” example (trait)

In the following example I want to create a special kind of user record, a user that has a phone number. The user is still conceptually a regular old user. The only difference is that this user happens to have a value for its phone_n…

All Ruby Podcasts by Devchat.tv 

RR 428: Arming the Rebels with Rails 6 Featuring David Heinemeier Hansson

Today’s guest is David Heinemeier Hansson, the creator of Ruby on Rails and co founder and CTO at Basecamp. This episode is focused on the release of Rails 6. David talks about the process of getting from Rails 5 to Rails 6 and some of the new features and frameworks in Rails 6. David describes some of the new features as ‘magical, which some people don’t like. He believes that the ‘magical’ element is a good thing because it reduces the learning curve for newcomers, so you can less time studying and more time being productive. This is important because it allows people from other platforms to jump on. Rails 6 will provide users with more frameworks so that they do not have to build all of…

Awesome Ruby Newsletter 

💎 Issue 243 - On Death and Dying: Ruby on Rails

zverok with ruby 

Rebuilding the spellchecker, pt.3: Lookup—compounds and solutions

This is the third part of the “Rebuilding the spellchecker” series, dedicated to the explanation of how the world’s most popular spellchecker Hunspell works.

Quick recap:

  1. In the first part, I’ve described what Hunspell is; and why I decided to rewrite it in Python. It is an explanatory rewrite dedicated to uncovering the knowledge behind the Hunspell by “translating” it into a high-level language, with a lot of comments.
  2. In the second part I’ve covered the basics of the lookup (word correctness check through the dictionary) algorithm, including affix compression.

This part is a carry-over of lookup algorithm explanation, dedicated to word compounding and some less complicated but…

Ruby Weekly 

Google Cloud Functions now supports Ruby

#535 — January 14, 2021

Read on the Web

Ruby Weekly

Buttons above are from React Social Login Buttons by Michal Szorád

OmniAuth 2.0 Released — OmniAuth is an extremely popular Rack-based authentication system that hasn’t seen a major update in years but continues to be used in thousands of Ruby and Rails apps. No huge new features, but sensible tweaks and security improvements abound. Here’s a guide to upgrading to 2.0 as it does have a few breaking changes.

OmniAuth Community

Google Cloud Functions Adds Ruby SupportCloud Functions is Google’s function as a service (FaaS) platform and they’ve now added…

Speedshop - Ruby on Rails performance consulting 

Announcing the Rails Performance Apocrypha


Hello Rubyists!

Today, I’m launching a new product: The Ruby on Rails Performance Apocrypha.

Over the last four years, I’ve written a lot of stuff to this newsletter. Until now, none of that stuff has been publicly accessible if you wanted to go back and read it again. If something useful was posted to the newsletter before you subscribed, you were just sort of screwed.

So, I’ve compiled 4 years of writing to this newsletter into a book. It covers my usual topics: performance science and engineering, frontend performance, Ruby performance, and scaling. It’s a fun ramble around all of these topics with a lot of tidbits and useful information scattered about. Each chapter is quite short,…

Hongli Lai 

An alternative to macOS's DYLD_LIBRARY_PATH

In my last blog post about Traveling Ruby's future, I said that it's hard to democratize the development of Traveling Ruby because of System Integrity Protection (SIP). Traveling Ruby's build process relies on DYLD_LIBRARY_PATH, which is blocked by SIP. This means that:

  • Contributors that build Traveling Ruby on their own laptops, must disable SIP.
  • Traveling Ruby cannot be built on many CI hosting services, such as Azure DevOps and Github Actions, because it's not possible to disable SIP there.

After some research and experimentation, I've found an alternative to DYLD_LIBRARY_PATH, meaning that it's no longer necessary to disable SIP. This significantly changes the ability to…

Boring Rails: Skip the bullshit and ship fast 

Magic Responsive Tables with Stimulus and IntersectionObserver

This is a guest collaboration with Pascal Laliberté, author of Modest JS Works, a short online book for those who want to write modest JavaScript, and then focus on all the other stuff that matters in building an app.

You’re working on this data table for your app. It’s mostly server-side HTML. Nothing fancy.

But as you’re adding columns, you’ve got a problem. How are you going to handle small screens?

The table has to scroll horizontally to let the user see all the columns. The table needs to become “responsive”.

In this article, we’ll look at a side-scrolling widget used in Shopify’s Polaris UI toolkit (currently built in React), and we’ll recreate the functionality using just Stimulus

Honeybadger Developer Blog 

Building, Testing and Deploying AWS Lambda Functions in Ruby

Developing software can be challenging, but maintaining it is far more challenging. Maintenance includes software patches and server maintenance. In this post, we will focus on server management and maintenance.

Traditionally, servers were on-premises, which means buying and maintaining physical hardware. With cloud computing, these servers no longer need to be owned physically. In 2006, when Amazon started AWS and introduced its EC2 service, the era of modern cloud computing began. With this type of service, we no longer needed to maintain physical servers or upgrade physical hardware. This solved a lot of problems, but server maintenance and resource management are still up to us. Taking…

RubyGems Blog 

December 2020 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 December.

RubyGems News

In December, we finally released bundler 2.2 and Rubygems 3.2 🎉. On the Bundler side, this minor release provides some major enhancements in how Bundler treats platforms, and also a few extra features. Check this blog post about bundler-v2-2 release for details. On the RubyGems side, the release provides a lot of bug fixes, a noticeable boot time speed-up, better integration in ruby-core and alternative implementations, and adds support for a…

After…

The Rails Tech Debt Blog 

How to Upgrade Rails Without a Test Suite

Sometimes you will be caught between a rock and a hard place. For example: You really need to upgrade your Rails application because Heroku is discontinuing your stack in two weeks so you don't have the time to write an entire test suite.

Sometimes the situation will be that your boss really needs you to upgrade Ruby or Rails to use a version that gets security updates and they won't allow you to write tests beforehand.

This article will explain how to ship a Rails upgrade project without a test suite. If your application has no tests, you will learn how to upgrade without having to write tests first.

  1. Set up Staging
  2. Check the Changelog
  3. Write a Testing Script
  4. Set up Error Tracking
  5. Set…
Schneems - Programming Practices, Performance, and Pedantry 

Migrating a Ruby Library from TravisCI to CircleCI

TravisCI.org is dead. Long live the new CI! TravisCI.org was THE way to run CI for an open source Ruby library. It was so easy that it was seemingly effortless. Even better, it was free. Since the slow-motion collapse of the product, developers have been pushed to other CI providers. I was recently tasked with transferring CI away from Travis for my library derailed_benchmarks and chose CircleCI. This post is a little about why I chose CircleCI, a little about how the transition worked, and a little about nostalgia.

Ruby Magic by AppSignal 

How to Use Mixins and Modules in Your Ruby on Rails Application

Modules and mixins are, without doubt, great resources that make Ruby so attractive. They give the application the ability to share the code that can be used with ease in other places. It also helps us organize our code by grouping functionalities and concerns, which improves the readability and maintainability of our code.

In this article, we will go through the concepts behind modules and mixins. We’ll learn how to create and mix modules into other classes and discuss the benefits of using them in a Ruby on Rails application.

I hope you’ll enjoy the journey!

What are Modules

Modules are one of the shiniest resources of Ruby because they provide two great benefits: we can create…

Hi, we're Arkency 

How well Rails developers actually test their apps

How well Rails developers actually test their apps

Here are the results of our State of Testing in Rails apps survey results. I have distilled the most interesting numbers for your reading pleasure and efficiency. Detailed charts here. I have highlighted what stands out as interesting for me. Number of surveyees: 142. Thanks for being one!

  • 80% favor RSpec
  • 79% find testing is inseparable from software development
  • 54% say their app is well-tested
  • 93% rely on unit tests
  • 30% work with a project with over 100 db tables
  • 33% work in a team of two or three
  • 18% run a single test in “blink of an eye”, 46% under 5s
  • 19% need more than half an hour to run the full suite on a development machine
  • 86%…
Ruby on Rails Podcast 

353: Hanami 2.0 with Tim Riley

Tim Riley is a long-time Rubyist and is a core team member of the Hanami, dry-rb, and rom-rb open source projects. He guested on the show to discuss the eagerly anticipated Hanami 2.0 release, how dry-rb, rom-rb and Hanami partnered and how slices and containers work with one another.

Links for this episode:

Brought to you by:

Scout APM

Give Scout APM a try for free today and Scout will donate $5 to the open source project of your choice when you…

Linode

BigBinary Blog 

Additional database-specific rake tasks for multi-database users

Rails 6.1 provides additional tasks to work with a specific database when working in a multi database setup.

Before Rails 6.1, only the following tasks worked on a specific database.

  • rails db:migrate:primary
  • rails db:create:primary
  • rails db:drop:primary

But some tasks that could be applied to a specific database were missing. Let's checkout an example.

Before Rails 6.1, running a top level migration on a multi-database project, dumped the schema for all the configured databases, but if a database specific migration was run, the schema was not dumped. And there were no tasks to manually dump the schema of a specific database.

> rails db:schema:dump:primaryrails aborted!Don't know how to build task…
Greater Than Code 

217: Robots As "Social Entities" with Laura Major

02:05 - Laura’s Superpower: Problem Solving

04:07 - What to Expect When You’re Expecting Robots

06:59 - The Human/Robot Partnership

  • Robot Personification
  • Positives and Negatives
  • Robots Will Never Be Perfect
  • Making Our World “Robot Compatible”

14:34 - Human Behavior Towards Robots; Vice-Versa

20:38 - Robots as “Social Entities”

  • Safety Transcending Competition
  • Contextualization
    • Observable
    • Predictable
    • Directable

24:43 - How Media Affects The Way People View Robots

  • Science-Fiction…
Code with Jason 

Nested factories in Factory Bot: what they are and how to use them

Sometimes you want to be able to create records that are 95% the same as the “default” but have one or two small differences.

Physician user example

Let’s use the following as an example. Let’s say that in the majority of your application’s tests that involve a User, you want just a regular old user. Maybe you have 30 such tests.

But for a handful of tests you want to use a special kind of user, a user that indicates that the person using the application is a physician.

In this scenario, the technical difference between a “physician user” and a regular user is that a physician user has a role attribute that’s set to 'physician'. Let’s say there are 6 tests that use a physician user.

Options…

Riding Rails 

Hello 2021: Sole record, Same form multiple verbs, Validator with range, Rich text control

Hi there. Andy here, with the first newsletter of 2021, highlighting some updates to Ruby on Rails over the last few weeks. Let’s jump right in!

Find and assert the presence of exactly one record

Add FinderMethods#sole and #find_sole_by to find and assert the presence of exactly one record.

Submit the same form with different HTTP methods

This change provides the ability to post the same form with different HTTP methods. For example PUT and a DELETE requests can be made from the same form.

Validate numericality with a Range

A Ruby range can now be provided as part of a numericality validator.

Improve Action Text extensibility

Allow the HTML surrounding rich text to be customized…

Julia Evans 

Server-sent events: a simple way to stream events from a server

hello! Yesterday I learned about a cool new way of streaming events from a server I hadn’t heard of before: server-sent events! They seem like a simpler alternative to websockets if you only need to have the server send events.

I’m going to talk about what they’re for, how they work, and a couple of bugs I ran into while using them yesterday.

the problem: streaming updates from a server

Right now I have a web service that starts virtual machines, and the client polls the server until the virtual machine is up. But I didn’t want to be doing polling.

Instead, I wanted to stream updates from the server. I told Kamal I was going to implement websockets to do this, and he suggested that…

Rails with Jason 

079 - Dockerizing Rails Applications with Mike Rogers, Founder of TypoCI

In this episode I talk with Mike Rogers about how to Dockerize Rails applications. We talk about the difference between Dockerizing for development and Dockerizing for production, mount volumes, performance trade-offs, and more.

Links:

Hi, we're Arkency 

Gradual automation in Ruby

Gradual automation in Ruby

It’s the simplest piece of Ruby code you’ll read today. I originally stumbled upon it here, where it’s referred as do-nothing scripting. I have yet another name for it, though: Puts-First Automation or Puts-Driven Automation.

Problem

You want to codify a manual process like setting up another instance of your e-commerce app. It may involve several steps with varying potential for automation (like seed the db, set up a subdomain, set up admin account).

  • Solution 1 📖: lay out all steps in a wiki page and teach people to conform.
  • Solution 2 🧠: don’t even document the steps, keep it in your own head. Have people always come to you or discover it from scratch, develop…
The Bike Shed 

276: Ride-Along Files

On this week's episode, Chris shares a new favorite tool for querying JSON and Steph revisits a previous deployment issue. They also dive into the new features in Ruby 3, ponder the idea of adding types to Ruby, revisit breaking changes, and round out the conversation with a listener question about managing tmux sessions.


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


Become a Sponsor of The Bike Shed!

Sponsored By:

ruby – Bibliographic Wilderness 

Gem authors, check your release sizes

Most gems should probably be a couple hundred kb at most. I’m talking about the package actually stored in and downloaded from rubygems by an app using the gem.

After all, source code is just text, and it doesn’t take up much space. OK, maybe some gems have a couple images in there.

But if you are looking at your gem in rubygems and realize that it’s 10MB or bigger… and that it seems to be getting bigger with every release… something is probably wrong and worth looking into it.

One way to look into it is to look at the actual gem package. If you use the handy bundler rake task to release your gem (and I recommend it), you have a ./pkg directory in your source you last released…

RubyGems Blog 

3.2.5 Released

RubyGems 3.2.5 includes bug fixes.

To update to the latest RubyGems you can run:

gem update --system

To install RubyGems by hand see the Download RubyGems page.

## Bug fixes:

  • Don’t load more specs after the whole set of specs has been setup. Pull request #4262 by deivid-rodriguez
  • Fix broken bundler executable after gem update --system. Pull request #4221 by deivid-rodriguez

SHA256 Checksums:

  • rubygems-3.2.5.tgz
    c1ca643ca2a9fc643eebbc2f59afb2a37f1e84edfe921e45b7f1bfbced6e5f73
  • rubygems-3.2.5.zip
    478ad49aaf0637b353e9552eff60f9cd839f434e8fb9a34ab7759ca717ed6297
  • rubygems-update-3.2.5.gem
    e7bd149bd2756c2543794196cf7e4d3b7b2e061f5bbc48346c2e4f5037c0ed33
Hi, we're Arkency 

4 strategies when you need to change a published event

4 strategies when you need to change a published event

Event versioning — you’ll need it one day anyway. You publish an event. You handle it in some consumers, perhaps aggregates or process managers. Soon you realize you need to change something in the event’s schema… Like adding an attribute, filling up a missing value, flattening the attribute structure. What do you in such a situation?

0. Mutate past events 😧

Meaning you just loop over the past events that need to change and mutate their payload in the database. You might be tempted to do it using RES internals:

RailsEventStoreActiveRecord::Event.where(event_type: "SomethingHappened").find_each do |record|
  record.data[:new_attribute] =

But please do not. There’s an api exactly for this purpose described in the RES docs:

ev…
Engine Yard Blog 

Engine Yard Kontainers Is Now Generally Available

We are delighted to announce that the Engine Yard Kontainers is now LIVE.  Engine Yard Kontainers (EYK), is a fully managed container-based infrastructure to run your applications without building DevOps expertise. We introduced EYK in July 2020 as an alpha version. Thanks to many of our customers who worked closely with us from alpha to GA.

Andy Croll 

Read the .ruby-version into your Gemfile

Previously I recommended using a loose version ruby version constraint in your Gemfile. This is still a valuable technique, but here’s another useful variation that’s works well for most of us, most of the time.

Hat tip to Emma for the this one-liner.

Ruby version managers (such as chruby) ensure an application uses a specific version of Ruby by looking for a .ruby-version file in the root directory of each app.

The file specifies the required version of Ruby for the application and the manager automatically switches the environment to use the specified version.

The version can also be specified in your Gemfile using bundler, which is more often used to define the version of Ruby to use…

Instead of…

…specif…

Saeloun Blog 

Rails 6.1 adds support for role switching and sharding in database

Rails 6.1 adds the ability to switch a role or shard for an application with multiple databases. This means it is possible to switch connections for one database instead of all databases globally.

To use this feature, we need to set the below config in our application.

config.active_record.legacy_connection_handling = false

Let’s say we have two databases, primary and vehicles. And we have shards and replica configured for each of them in database.yml as below:

production:
  primary:
    database: primary_database
    adapter: mysql
  primary_replica:
    database: primary_database
    adapter: mysql
    replica: true
  primary_shard_one:
    database: primary_shard_one
    adapter: mys…
Saeloun Blog 

Rails 6.1 adds support for check constraints to database migrations

For adding check constraints until now with Rails, we had to execute raw SQL queries using migrations.

Example

Suppose we want to create a table for Book model with a check constraint on price field that price should be greater than 100. The only way to do this earlier was to write a migration with a raw sql query after creating table as given below:

class CreateBooks < ActiveRecord::Migration
  def change
    create_table :books do |t|
      t.string :name
      t.integer :price
    end
  end
end
class AddConstraintToBooks < ActiveRecord::Migration
  def up
    execute "ALTER TABLE books ADD CONSTRAINT price_check CHECK (price > 100)"
  end

  def down
    execute "ALTER TABLE books…

Moreover, this was an irreversible migration hence had to add it separately with up and down methods.

S…

zverok with ruby 

Rebuilding the spellchecker, pt.2: Just look in the dictionary, they said!

This is the second part of the “Rebuilding the spellchecker” series, dedicated to the explanation of how the world’s most popular spellchecker Hunspell works.

Quick recap: In the first part, I’ve described what Hunspell is; and why I decided to rewrite it in Python. It is an explanatory rewrite dedicated to uncovering the knowledge behind the Hunspell by “translating” it into a high-level language, with a lot of comments.

Now, let’s dive into how the stuff really works!

There are two main parts of word-by-word spellchecker algorithms:

  1. Check if a word is correct: “lookup” part
  2. Propose the correction for incorrect words: “suggest” part

Hunspell also implements several other…

Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 7 - merkletree Gem - Build Your Own Crypto Hash Trees - Grow Your Own Money on Trees

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. What’s a Merkle Tree? A Merkle tree or hash tree is a tree in which every leaf node is labelled with the hash of a data block and every non-leaf node is labelled with the cryptographic hash of the labels of its child nodes. Hash trees allow efficient and secure verification of the contents of large data structures. […] The concept of hash trees is named after Ralph Merkle who patented it in 1979. – Wikipedia Usage Pass along all (leaf / data block) hashes as strings or…
Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 7 - centralbank Gem - Print Your Own Money / Cryptocurrency - Run Your Own Federated Central Bank Nodes on the Blockchain Peer-to-Peer over HTTP

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. What’s centralbank? Use the centralbank command line tool. Try: $ centralbank -h resulting in: Usage: centralbank [options] Wallet options: -n, --name=NAME Address name (default: Alice) Server (node) options: -o, --host HOST listen on HOST (default: 0.0.0.0) -p, --port PORT use PORT (default: 4567) -h, --help Prints this help To start a new (network) node using the default…
Josh Software 

Updating Embedded Documents in Mongoid

I faced a situation in my project where I need to update all the embedded documents. But as we generally know about the mongoid embedded documents we can’t access directly, we must access them through parent documents. I have millions of such parent documents and they embed many child documents. So in the general solution, … Continue reading Updating Embedded Documents in Mongoid
Ruby on Rails Podcast 

352: Haml Sparks Joy with Hampton Lintorn Catlin

Hampton Lintorn Catlin is the creator of Sass, Haml, Wikipedia Mobile, and more. Hampton is Co-Founder and CEO of Veue, a live streaming video platform. If you love Haml, this episode is for you.

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…

Hi, we're Arkency 

Low-boilerplate process manager

A low-boilerplate process manager

Process Manager — you can think of it as something that takes events on input and produces a command on output. You might have found yourself in situations, where you felt you should be implementing one.

A simple example that often happens: you’re familiar with event handlers, but at some point it seems like you need an event handler that would activate after two distinct events happen — not just one. Often people are tempted to propagate attributes in events. It’s rarely a good idea. It might be a good place to employ a process manager.

Typically, to implement it, you handle specific events and store process manager state in an plain ol’ active record —…

Julia Evans 

Daily blog posts about my time at RC

A quick note: I’ve been writing some daily-ish blog posts about what I’ve been doing in my time at the Recurse Center, but I took them out of this RSS feed because I think they’re a bit more stream of consciousness than my usual posts. Here’s where to find them if you’re interested:

Remote Ruby 

Andrew's HAML Tattoo

[00:01:41] Jason dropped his StimulusReflex course in early access and he tells us how the initial reception of it is and how he’s feeling about it.
[00:09:21] Andrew explains the differences between Snowpack’s more like Webpacker, and he mentions Skypack and Snowpack pair very nice together. [00:18:07] Andrew tells us that Webpack is just a bunch of Webpack config rolled into a nice easy to use and they took most of the use cases of Webpack and bundled it into a gem. He mentions the web server in Ruby, Falcon, which is HTTP/2 compatible. [00:24:29] Andrew asks the guys if they know what Vercel is (formerly ZEIT) and how he tested it out. 
[00:28:25] What else is new in the Ruby…
Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 6 - kittyverse Gem - Inside the CryptoKitties 256-Bit Genome - Slice 'n' Dice Unique Bits 'n' Bytes - 48 Genes (12 Traits x 4 P, H1, H2, H3) - Build Your Own CryptoKitties Gene Reader - The Future is Meow

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. Fabulous Persian Spock Gerbil Gold Cottoncandy - Extremely rare gen 5 swift virgin | 2.9 ETH Rarity: 0.00264% Gen 5 JAGUAR FABULOUS GOLD DALI!! VIRGIN! Rarity: 0.0015% Princess Bubblegum is now for sale! Gen 12 | Brisk | Virgin | Chartreux | Bubblegum | Otaku | Emeraldgreen | Saycheese | Mauveover | Spock - Starts ETH 20/Ends ETH 10 Gold ducat, Gen 5, Virgin, Swift. Very cheap Cheap Gen 1 cute kittie with rare genes! Only 0.125 ETH UNIQUE Virgin Peach Googly…
Riding Rails 

Rails 6.1.1 has been released

Hi everyone,

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

CHANGES since 6.1.0

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

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

6.1.1 CHANGELOG

Full listing

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

SHA-256

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

Awesome Ruby Newsletter 

💎 Issue 242 - Ruby: How Can Something So Beautiful Become So Ugly

Ruby Weekly 

What Turbolinks Did Next

#534 — January 7, 2021

Read on the Web

👋  We're back! I'm looking forward to another strong year for Ruby and things are continuing to look up with both the release of Ruby 3.0 and ongoing Rails developments. As always, if you have anything for us to check out, hit reply and we'll take a look.
__
Peter Cooper, your editor

Ruby Weekly

Hotwire: HTML Over The Wire (or.. What Turbolinks Did Next) — Dropped just before Christmas, Hotwire is the end result of a project DHH was calling “NEW MAGIC” on Twitter last year. If you remember the “build a blog in 15 minutes with Rails” video from 2005, the…

Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 5 - ecdsa Gem - Open Up 10,000,000,000 Accounts - Bank the Unbanked Using Elliptic Curve (EC) Cryptography and the Digital Signature Algorithm (DSA) - Be Your Own Bank

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. Let’s start with a trivia quiz. Q: How long does it take to open up 10 000 (bank) accounts? ( A ) 1 second ( B ) 1 minute ( C ) 1 hour ( D ) ___ Other, please tell. Did you know? All you need to open up a new account on a blockchain is an (unsigned) 256-bit / 32 byte integer number. Yes, that’s it. No questions asked. The private key is the secret “magic” that unlocks your own bank. Remember: NEVER share your private keys! Not your keys, not your money! If your…
Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 5 - elliptic Gem - Open Up 10,000,000,000 Accounts - Bank the Unbanked Using Elliptic Curve (EC) Cryptography and the Digital Signature Algorithm (DSA) - Be Your Own Bank

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. Let’s start with a trivia quiz. Q: How long does it take to open up 10 000 (bank) accounts? ( A ) 1 second ( B ) 1 minute ( C ) 1 hour ( D ) ___ Other, please tell. Did you know? All you need to open up a new account on a blockchain is an (unsigned) 256-bit / 32 byte integer number. Yes, that’s it. No questions asked. The private key is the secret “magic” that unlocks your own bank. Remember: NEVER share your private keys! Not your keys, not your money! If your…
Hongli Lai 

The future of Traveling Ruby

A couple of years ago, I had a dream: to make it dead-easy to distribute Ruby CLI apps to end users, without requiring those users to install Ruby or muck about with gems and Bundler. And thus Traveling Ruby was born.

Traveling Ruby hasn't seen updates for quite a while now. Recently I tried making a new bugfix release, but I found it to be more challenging than I had hoped. In this article I reflect on those challenges, as well as on the future of Traveling Ruby.

The dream of a single, self-contained package

Back in the 90s, I wrote Windows desktop apps with Delphi. Unlike its contemporary competitors such as Visual Basic and Java, which generated apps that required users to install a…

BigBinary Blog 

Rails 6.1 adds strict_loading to warn lazy loading associations

Rails 6.1 adds strict_loading mode which can be enabled per record, association, model or across the whole application.

strict_loading mode is an optional setup andit helps in finding N+1 queries.

Let's consider the following example.

class Article < ApplicationRecord  has_many :commentsendclass Comment < ApplicationRecord  belongs_to :articleend

Mark a record for strict_loading

When strict_loading mode is enabled for a recordthen its associations have to be eager loadedotherwise Rails raises ActiveRecord::StrictLoadingViolationError.

Let's see this use case by setting strict_loading mode for an article record.

2.7.2 :001 > article = Article.strict_loading.first  Article Load (0.2ms)  SELECT…
Ruby on Rails Podcast 

352: Haml Sparks Joy with Hampton Lintorn Catlin

Hampton Lintorn Catlin is the creator of Sass, Haml, Wikipedia Mobile, and more. Hampton is Co-Founder and CEO of Veue, a live streaming video platform. If you love Haml, this episode is for you.

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…

Kir Shatrov 

Ruby 3, concurrency and the ecosystem

With the Ruby 3.0 release, there’s been a lot of chatter about concurrency, parallelism, and async IO.

For my own reflection, I wanted to write down what that means for performance and capacity/costs of apps, and what would be the impact on the Ruby ecosystem.

I will assume that the audience already knows the difference between threads vs processes model in UNIX and the Little’s law.

Updated on Jan 9, 2021: thanks to the feedback from Samuel Williams, I’ve revised the post with findings from Falcon, the async web server written in Ruby.

Learning from Python

It’s always good to take learnings from other languages. There’s an excellent write-up “Async Python is not faster” by Cal…

Greater Than Code 

216: Robot and Human Collaboration with Julie Shah

02:21 - Julie’s Superpower: Working Really Hard and Maintaining Focused Attention on Things for a Long Period of Time

04:25 - Robotics and Working in Artificial Intelligence (AI)

11:10 - Structuring and Optimizing the World for Machines, AI, and Robots

26:10 - Understanding Output and Building Calibrated Trust

  • Mental Models

33:39 - Robots and Humans in Public Spaces

  • Predictability
  • Directability
  • Standardization
Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 4 - cryptoquotes Gem - I HODL, You HODL, We HODL! - BREAKING: BITCOIN JUST BROKE $22 000! - Get Free Oracle Sayings About the New New 'In Math We Trust' Ponzi Economics

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. SEC Investor Education: New Year’s Financial Resolution: Avoid too-good-to-be-true “investments” with Ponzi scheme “red flag” claims like: “To the moon! To the mars!” “Number go up!” “Yearly return of 300+% in 2020!” “Could quadruple in 2021 and rally to $100,000!” What’s Crypto Quotes? The cryptoquotes gem includes the oracle command line tool that gets you a free random crypto quote of the day on the new new “in math we trust” ponzi economics - on…
zverok with ruby 

Rebuilding the most popular spellchecker. Part 1

How I decided to write a spellchecker and almost died trying

A few years ago I had a fun idea for a “weekend project”: pure-Ruby spellchecker. Ruby is my language of choice, and no-dependencies spellchecker seemed a small useful tool for the CI environment: for example, to check comments/docs spelling without installing any third-party software. I actually could’ve pulled out the project in its limited scope (only English, only spot misspelled words without fixing, limited dictionary) with just a flat list of known words, but that’s not what happened.

Back then, I decided to make a moderately generic tool, at least able to work with multiple languages. Fortunately (or so I believed!),…

Speedshop - Ruby on Rails performance consulting 

How To Use Turbolinks to Make Fast Rails Apps

A perceived benefit of a client-side JS framework is the responsiveness of its interface - updates to the UI are instantaneous. A large amount of application logic (and, usually, state) lives on the client, instead of on the server. The client-side application can perform most tasks without running back to the server for a round-trip. As a result, in the post-V8 era, many developers think traditional server-side languages and frameworks (Ruby, Python, even Java) are simply too slow for modern web applications, which are now supposed to behave like native applications, with instantaneous responses.

Is Rails dead? Can the old Ruby web framework no longer keep up in this age of “native-like”…

Speedshop - Ruby on Rails performance consulting 

The Complete Guide to Rails Caching

Caching in a Rails app is a little bit like that one friend you sometimes have around for dinner, but should really have around more often. Nearly every Rails app that’s serious about performance could use more caching, but most Rails apps eschew it entirely! And yet, intelligent use of caching is usually the only path to achieving fast server response times in Rails - easily speeding up ~250ms response times to 50-100ms.

A quick note on definitions - this post will only cover “application”-layer caching. I’m leaving HTTP caching (which is a whole nother beast, and not even necessary implemented in your application) for another day.

Why don’t we cache as much as we should?

Developers, by…

Speedshop - Ruby on Rails performance consulting 

Make your Ruby or Rails App Faster on Heroku

I’ve seen a lot of slow Ruby web apps. Sometimes, it feels like my entire consulting career has been a slow accumulation of downward-sloping New Relic graphs.

Why is the case? If you read that bastion of intellectual thought, Hacker News, you’d think it was because Go rocks, Ruby sucks, and Rails is crappy old-news bloatware. Also, something about how concurrency is the future, and dynamic typing is for fake programmers that can’t code.


And yet, top-1000 websites like Basecamp, Shopify and Github consistently achieve server response times of less than 100 milliseconds with Rails. That’s pretty good for a dynamic, garbage-collected language, if you ask me.

Most of my clients deploy on…

Jemma Issroff 

IRB’s Custom Measure Procedures

If you came here from my post about IRB’s built-in measure command, thanks for reading part two too! If not, that is a good place to start learning about IRB’s measure command!

Custom measure procedures

Measure can also output the results of custom measurement procedures. The rest of this blog post will work through an example of creating a custom measurement procedure, and in doing so, demonstrate how you could write your own ones for your needs.

I’m a big fan of using Speedscope for flamegraph visualizations. In order to produce a flamegraph, Speedscope needs a profile of our code. Speedscope can take json formatted Stackprof output. So, let’s continue with our Stackprof theme, and…

Jemma Issroff 

IRB’s Built-in Measure

When reading the official Ruby 3.0 release post, one bullet caught my eye especially. With Ruby 3.0, IRB introduced a measure command. As someone who often times little snippets when debugging, comparing code, or writing new code, I was intrigued! IRB’s new measure command is a quick and easy way to measure different snippets from an IRB console.

Toggling measure

As the release notes demonstrated, we can toggle measure on by using measure (or measure :on), and off by using measure :off

irb(main)> measure
TIME is added
=> nil

irb > sleep 1
processing time: 1.000649s
=> 1

irb > 1
processing time: 0.000025s
=> 1

irb > measure :off
=> nil

By default, as we can see above, the IRB console…

GoRails Screencasts 

How to upgrade from Turbolinks to Hotwire & Turbo

Upgrading from Turbolinks to Hotwire is actually pretty simple now that Turbo handles error responses
All Ruby Podcasts by Devchat.tv 

RUBY 483: Unlocking the Power of Functional Programming and Elm with Richard Feldman

Richard Feldman - author of Elm in Action - joins the Rogues to discuss the advantages of Functional Programming and using Elm. Elm is a programming language that is a functional programming language built for the front-end that compiles to JavaScript. Due to its set of enforced assumptions, it leads to clean code and powerful programming constructs.

Panel

  • John Epperson
  • Luke Stutters

Guest

  • Richard Feldman

Sponsors

Links

Picks

Rails with Jason 

078 - StimulusReflex with Jason Charnes

In this episode I talk with Jason Charnes about StimulusReflex. Jason and I cover what StimulusReflex is as well as some of the core concepts of the technology.

Links:

Ruby Blockchain Week 2021, January 3rd to January 9th - 7 Days of Ruby (Crypto) Gems 

Day 3 - universum Gem - Operate the Ponzi Governmental - Real World Case Study - Last Creditor (Before Collapse) Wins the Jackpot!

Written by Gerald Bauer A code monkey formerly at Big Korupto. Jobless no coiner having fun staying poor and wrong. Writing the Get Rich Quick “Business Blockchain” Bible - The Secrets of Free Easy Money. Ponzis and Pyramids Simple Ponzi - Investment of a Lifetime! Let’s start with a simple ponzi scheme contract - coded in small, smart, secure, safe, solid & sound (S6) ruby running on the universum personal blockchain runtime: class SimplePonzi < Contract def initialize @current_investor = msg.sender @current_investment = 0 end def receive # note: new investments must be 10% greater than current minimum_investment = @current_investment * 11 / 10 assert(…
The Bike Shed 

275: In Search of An Acronym

On this week's episode, Steph and Chris revisit their discussion about testing rack rewrite redirect logic, mystery guests, DNS configuration, and trying very hard to not be too dogmatic. Steph describes her recent work trying to debug failing deploys with Concourse, Kubernetes, and Google Cloud while touching on blue-green deployment and secrets management. Finally, Chris talks about porting a svelte project to typescript and the trade-offs of adding Types upfront vs types after the fact, and the parallels to testing and TDD.


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…


Julia Evans 

Docker Compose: a nice way to set up a dev environment

Hello! Here is another post about computer tools that I’ve appreciated. This one is about Docker Compose!

This post is mostly just about how delighted I was that it does what it’s supposed to do and it seems to work and to be pretty straightforward to use. I’m also only talking about using Docker Compose for a dev environment here, not using it in production.

I’ve been thinking about this kind of personal dev environment setup more recently because I now do all my computing with a personal cloud budget of like $20/month instead of spending my time at work thinking about how to manage thousands of AWS servers.

I’m very happy about this because previous to trying Docker Compose I…