news, opinion, tutorials, about ruby, aggregated
Sources About
Code with Jason 

How I Write Model Tests (Part 1)

I recently read a post on /r/ruby that asked for RSpec model testing best practices. I gave an answer, but also wanted to give some concrete examples, so here we go.

What follows is how I’d write a spec for a new model. I actually took a model from an existing application I wrote and just blew away the code so I could start over from scratch.

Once I got a ways into this post I realized that it was getting pretty long and I still hadn’t gotten very far into the “meat” of how I’d write a model spec. So I intend to write a follow-up post that goes more in-depth.

Starting point

Here’s what my Restaurant model and test look like when they’re empty.

class Restaurant < ApplicationRecord

Running with Ruby 

Ubuntu 18.04 – Disable screen on lid close

In order to force your Ubuntu to just disable the screen on lid close, you need to do two things:

  1. Disable sleep (do nothing) on lid close
  2. Disable screen on lid close

Just follow all the steps from both sections and you should be fine.

Disable sleep (do nothing) on lid close

Copy-paste this into the terminal (as a root):

# sudo su
echo 'HandleLidSwitch=ignore' | tee --append /etc/systemd/logind.conf
echo 'HandleLidSwitchDocked=ignore' | tee --append /etc/systemd/logind.conf
sudo service systemd-logind restart

Disable screen on lid close

Copy-paste this into the terminal (as a root):

# sudo su
echo 'event=button/lid.*' | tee --append /etc/acpi/events/lm_lid
echo 'action=/etc/acpi/'…
Riding Rails 

Cookies with purpose, Array extract! and more

Welcome in this week news edition from Rails world. This is Wojtek bringing you summary of latest activities.

Once Webpacker is the default in rails/master, we’ll be unveiling the alpha version of a brand-new exciting framework for Rails 6.0 😄.

If you can’t wait, help us testing Webpacker integration so it can be merged and mystery revealed.

Add Purpose Metadata to Cookies

Adds purpose metadata to cookies so that the value of one cookie cannot be copied and used as the value of another cookie.

Add Array#extract!

The method removes and returns the elements for which the block returns a true value.

numbers = [1, 2, 3, 4]
odd_numbers = numbers.extract!(&:odd?) # => [1, 3]
numbers # =>…
Appfolio Engineering 

Rake Does What?: A Debugging Story

The Mystery

While working on upgrading one of our apps to Rails 5 I noticed that suddenly migrations were failing with the following error:

StandardError: An error has occurred, all later migrations canceled:
wrong number of arguments (given 2, expected 1)

The migration it was failing on just had something like this:

class LeakyMigration < ActiveRecord::Migration[4.2]
  results = select_one <<~SQL
    SELECT 1 FROM table_name

  if results
    raise "Panic!"

Digging into the ActiveRecord 4.2 and 5.0 documentation it became pretty clear that there wasn't a change to the method signature for select_one, so what gives? Looking at the stack trace I noticed that the method call was…

Engine Yard Blog 

Take Out The Papers And The Trash

How to clean and clear large tables in MySQL

From time to time our data team gets requests for advice on how to perform cleanup operations against large database tables. Typically, these originate in a ticket requesting information about how the disk is being used or why a specific table is performing poorly.

Somewhat less often, we are asked us to explain why a cleanup attempt has failed or why it has caused downtime for an application. Managing these types of operations with minimal or no downtime can be a challenge given the way a database like MySQL performs these tasks.

The most common form of table cleanup operation we are asked about is for the sessions table. Even…

Awesome Ruby Newsletter 

Issue 117 - The often overlooked consideration when choosing Ruby as your next programming language


Depfu supports monorepos now

We’ve just deployed the last missing pieces and can now say this with conviction: Depfu fully supports monorepos.

Not sure if it’s a trend or just my brain pattern matching, but we had more and more of our users ask us if we can handle monorepos. We actually kinda supported them for a while now, but it involved manual setup steps and a few hacks. Now it’s all polished and working nicely.

So this is what happens if you use Depfu with a monorepo, or just have your Gemfile/package.json in a non-root folder:


When you enable a repo in Depfu, we first try to find a Gemfile/package.json in your root folder. If there is none, we iterate through your subfolders and see if we can…


Ruby logs and puts not shown in docker container logs

Capturing Rails (or plain Ruby) logs in Docker logs output is needed when you are configuring some log agregation tool like Kibana that will proces logs directly from Docker container output.

Given you are using Ruby 2.5.1 Docker image in Rails project, you may notice that no logs are beeing output to docker stdout (or docker compose stdout) output even when you configure your logger to be logger =

# config/enviroments/production.rb

Rails.application.configure do
  # ...
  config.logger =
  config.level = 0
  # ...

Rails.logger.warn "this should appear in Docker output but it will not""this should also appear in…
Ruby Weekly 

Turn Ruby into a versatile Command Line Utility

#412 — August 16, 2018

Read on the Web

Ruby Weekly

rb: Turn Ruby Into a Versatile Command Line Utility — Weighing in at a mere 10 lines, rb is a clever approach to making Ruby an even handier chainable CLI tool for manipulating and extracting data. Be sure to check the examples.


Kimurai: A Modern Web Scraping Framework — Works with headless Chrome or Firefox, PhantomJS, or simple, regular HTTP requests to scrape even sites that require JavaScript to render.

Victor Afanasev

Continuous Delivery on Modern Infrastructure - Run GoCD on Kubernetes — Model Docker-based build workflows more…

Giant Robots Smashing Into Other Giant Robots 

Deprecating static attributes in factory_bot 4.11

factory_bot has traditionally allowed you to define attributes dynamically, with a block:

factory :robot do
  name { "Ralph" }

or statically:

factory :robot do
  name "Ralph"

With the dynamic version, every time you build a new robot you will get a new “Ralph” string for the name, whereas in the static version you will always get the same string (i.e. the same object in memory).

Static attributes have been a source of much confusion over the years. A large number of our GitHub issues and Stack Overflow questions have been related to this confusion, and we have been thinking about deprecating static attributes since 2013.

Getting the same string for every robot name is not…

BigBinary Blog 

Debugging failing tests in puppeteer because of background tab

We have been using puppeteer in on of our projects to write end-to-end tests. We run our tests in headful mode to see the browser in action.

If we start puppeteer tests and do nothing in our laptop (just watch the tests being executed) then all the tests will pass.

However if we are doing our regular work in our laptop while tests are running then tests would fail randomly. This was quite puzzling.

Debugging such flaky tests is hard. We first suspected that the test cases themselves needed more of implicit waits for element/text to be present/visible on the DOM.

After some debugging using puppeteer protocol logs, it seemed like the browser was performing certain actions very…


Fast Lookup & Unique Elements With The Ruby Set Class

A set is a class that can hold items in a similar way that an array does… …but with some special attributes. With the main benefit being this: All the items in a set are guaranteed to be unique. In this Ruby tutorial you’ll learn: How & when to use a set for maximum benefit […]

The post Fast Lookup & Unique Elements With The Ruby Set Class appeared first on RubyGuides. Don't miss your free gift here :)

bogdanvlviv / Bogdan 

Array#extract! to Active Support 6.0

TL;DR? #33137.

I have worked on a task, which included handling an array of data, recently. I needed to extract a data that satisfy some condition from the array, without losing the rest of the data that do not satisfy the condition, and then handle those arrays of data differently.

There are a lot of instance methods in the Array class, so I started looking for an appropriate method that would help me easily to do that.

I looked at Array#select!, but it did not work in my case since it

Invokes the given block passing in successive elements from self, deleting elements for which the block returns a false value.

If changes were made, it will return self, otherwise it…

numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
odd_numbers = num…
Bundler Blog 

July 2018 Bundler Update

Welcome to the July Bundler update!

We released Bundler 1.16.3 on July 17. The new release includes support for the upcoming Ruby 2.6, and fixes several bugs including symlink handling, temporary file handling, and improving error messages around filesystem access and installation errors.

Since we announced the new RFC process last month, we’ve seen new comments and new proposals in the Bundler RFC repo. If you’re interested in ideas for the future of Bundler, definitely take a look. Keep the comments and suggestions coming!

In other exciting news, we added a new contributor to the core team. Welcome David Rodríguez to Bundler! Probably best known for his work on the byebug debugger gem,…

All Ruby Podcasts by 

MRS 056: Sean Fioritto

Panel: Charles Max Wood

Guest: Sean Fioritto

This week on My Ruby Story, Charles talks to Sean Fioritto. Sean is a developer that five years ago quit his job to do his own thing and work on different projects such as Sketching with CSS, Angular Escape Plan training, and consulting. He first got into programming when he had an idea to create things such as rooms and spells in his MOO game. They talk about how he got into professional style programming, how he got into drawing with CSS, why he created the Angular Escape Plan, and more!

In particular, we dive pretty deep on:

Greater Than Code 

093: BOOK CLUB! Cybernetic Revolutionaries with Eden Medina

In this book club episode, we talk to Eden Medina: author of Cybernetic Revolutionaries: Technology and Politics in Allende's Chile about speaking as an expert, sociotechnical engineering, and of course, cybernetics. We have interactive show transcripts! Powered by Gretta. 

My Best Career Move

A Dallas Ruby Brigade meeting with a speaker talking to a room.

When I first started going to the Dallas Ruby Brigade (DRB) I was silent. I might as well have been invisible. A fly on the wall. I didn’t want to embarrass myself.

At the time, I was working in Perl and PHP and I wanted out. I tried a few languages and found myself really enjoying Ruby. I wanted to learn more about it and this group could teach me. I wanted to teach and present and this group could watch me. I wanted a job doing Ruby and this group could get me hired.

I also knew that to do these things effectively I’d have to network. You can’t network if you don’t talk.

OmbuLabs Blog 

Upgrade Rails from 5.1 to 5.2

This article is part of our Upgrade Rails series. To see more of them, click here.

This article will cover the most important aspects that you need to know to get your Ruby on Rails application from version 5.1 to 5.2.

  1. Ruby version
  2. Gems
  3. Config files
  4. Application code
    1. Active Storage
    2. Credentials
  5. Next steps

1. Ruby version

Like Rails 5.0 and 5.1, Rails 5.2 requires at least Ruby 2.2.2.

2. Gems

At the time of writing, the Rails 5.2 release is relatively recent, which means that some gems may still not be fully compatible, or contain deprecation warnings if you're not using their latest version. Ready4Rails can help you check if the gem is compatible with Rails 5.0, but it may…

BigBinary Blog 

Ruby 2.6 adds write_timeout to Net::HTTP

This blog is part of our Ruby 2.6 series. Ruby 2.6.0-preview2 was recently released.

Before Ruby 2.6, if we created a large request with Net::HTTP, it would hang forever until request is interrupted. To fix this issue, write_timeout attribute and write_timeout= method is added to Net::HTTP in Ruby 2.6. Default value for write_timeout is 60 seconds and can be set to an integer or a float value.

Similarly, write_timeout attribute and write_timeout= method is added to Net::BufferedIO class.

If any chunk of response is not written within number of seconds provided to write_timeout, Net::WriteTimeout exception is raised. Net::WriteTimeout exception is not raised on Windows systems.


BigBinary Blog 

Using Kubernetes ingress controller for authenticating applications

Kubernetes Ingress has redefined the routing in this era of containerization and with all these freehand routing techniques the thought of “My router my rules” seems real.

We use nginx-ingress as a routing service for our applications. There is a lot more than routing we can do with ingress. One of the important features is setting up authentication using ingress for our application. As all the traffic goes from ingress to our service, it makes sense to setup authentication on ingress.

As mentioned in ingress repository there are different types of techniques available for authentication including:

  • Basic authentication
  • Client-certs authentication
  • External authentication
  • Oauth…

In this blog, we will set up authentication…

Search Results for “ruby” – via @codeship 

How Ruby String Encoding Benefits Developers

Reading Time: 8 minutes

In the software and technology of today we see information in text form everywhere. Text that isn’t given to us in media formats such as images and videos are all stored internally in the computer as numbers with the encoding as the means we have to interpret how they should be read properly. This becomes much more evident when sharing mediums of text across languages where a persons system may not have support for it. And so this is why we as developers should familiarize ourselves with the tools we have for encoding and how we may best get the job done.

“How Ruby String Encoding Benefits Developers” via @codeship
Click To Tweet

Some basic history and Unicode


Julia Evans 

I started a corporation!

After I released Bite Size Linux in May, something surprising happened – it sold WAY more copies than I expected! (as of today, 2600 copies!!!). If you bought one, thank you! It was super encouraging and makes me want to produce a lot more fun zine ideas :). And 1300 of you have already bought Bite Size Command Line, which is similarly astonishing.

The only downside of selling things is – making money is complicated! I need to track the income so I can pay income taxes, I need to pay sales tax on Canadian sales! Tracking expenses is really annoying!

So I decided to start a corporation (just on the side, I still work at the same place ❤) to manage the logistics. I’m pretty excited about…

All Ruby Podcasts by 

RR 375: "How to Contribute to Ruby" with Sihui Huang


  • Eric Berry

Special Guests: Sihui Huang

In this episode of Ruby Rogues, the panel talks to Sihui Huang about his article "How to Contribute to Ruby." Sihui is currently a back-end engineer at Gusto, which is a startup that works with payroll, benefits, and HR for companies. They talk about her experience in the programming world, why she chose to work with Ruby, and they touch on her article and why she decided to write it. They also touch on the three focuses for Ruby 3, if she thinks Ruby has a long time future, and more!

In particular, we dive pretty deep on:

  • Sihui intro
  • Back-end engineer at Gusto
  • Working with Rails and Ruby
  • How old is the app?
  • How long have you been…
Ruby on Tales from a Codemancer 

Ruby 2.6 KeyError#initialize accepts message, receiver, and key as arguments

Ruby 2.6.0-preview2 was recently released. Ruby 2.5.0 introduced public instance methods KeyError#key and KeyError#receiver. You can read my earlier blog about KeyError#key & KeyError#receiver here. Ruby csv library raises a KeyError on CSV::Row#fetch method when the field is not found. def fetch(header, *varargs) # ... raise KeyError, "key not found: #{header}" # ... end Instead of raising a KeyError shown above, how about if this is possible? - raise KeyError.
Ruby – AWS Developer Blog 

Advanced client stubbing in the AWS SDK for Ruby Version 3

The AWS SDK for Ruby provides a robust set of features for stubbing your clients, to make unit tests easier and less fragile. Many of you have used these features to stub your client calls. But in this post, we’re going to explore both a new stub feature in version 3 of the AWS SDK for Ruby, and some advanced stubbing techniques you can add to your testing toolbox.

How to stub a client

The Aws::ClientStubs documentation has several examples of how to write client stubs, but in the most basic form, you do the following:

  1. Set the :stub_responses parameter at client creation.
  2. Write out the stubbed responses you want, sequentially.

For a simple example of stubbing an operation,…

Junior Developer 

Invalid or incomplete POST parameters

It took me [insert large number here] years of Rails and Ruby but I finally saw this in my logs:

Invalid or incomplete POST parameters

But the parameters were fine! It was just an innocuous XML document coming in through the API! After some flailing - basically bisecting a request payload - I reproduced it with:

$ curl -si -X POST -d '%' http://localhost/ | head -1
HTTP/1.1 400 Bad Request

To cut to the chase, adding a content type header solves it. With text/xml, we get a garden-variety 404 error since there's no route for a POST to /:

$ curl -si -H 'content-type: text/xml' -X POST -d '%' http://localhost/ | head -1
HTTP/1.1 404 Not Found

So the root cause is that if there's no…

Riding Rails 

Rails 5.2.1, skip caching nil entries and more

Namaste everyone! This is Prathamesh bringing you the latest news from the Rails world with some rain and chai from Pune.

Rails 5.2.1 is out in the wild

Rails 5.2.1 is released. Give it a try and check out all the awesome features.

Better error handling of Active Storage adapters

Now, the Active Storage service adapter names can be lower case or upper case. Also, a nice error message is printed if the service adapter class can’t be loaded.

Support for skipping caching of nil entries

While caching data from external services, sometimes we may get nil values. Most probably we don’t want to cache them. Here is an option skip_nil: true/false to skip caching of such entries.

Fix the issue…

Alfredo Motta 

The often overlooked consideration when choosing Ruby as your next programming language

When faced with the choice if Ruby should be your next programming language there is a lot to consider depending on your perspective. If you are new to the industry you might be looking for the fastest way to get a job, for example by checking how many companies are hiring Ruby developers. If you […]
Notes to self 

Using private GitHub repositories with yarn and npm in package.json

Whether you are working on a JavaScript project or a Rails one with Webpack you might come to the point where you need to reference a private GitHub repository as your dependency in package.json. Here are two options on how to do that.


First one is to use a special GitHub system user with access to the repository and generate an access token for this user that can be used directly as basic authentication in the HTTPS call. To do that go to Settings > Developer settings on GitHub. There you can switch to Personal access tokens and click Generate new token. Once you define the scopes for the token you can use this token in package.json as follows:

Julia Evans 

A few recent podcasts

In the last few months I was on a few podcasts. Maybe you will like them!

I find podcasts a little scary – my main medium is blogging/writing, which lets me edit it out when I say something in a confusing way. Can’t do that as well on a podcast! They seem to have turned out okay anyway, and I think practicing talking extemporaneously on a…

Appfolio Engineering 

Does ActionCable Smell Like Rails?

Not long ago, Rails got ActionCable. ActionCable is an interface to WebSockets and (potentially) other methods of turning a normal sent-to-browser web page into a two-way connection that can keep exchanging data. There have been a lot of these attempts over the years - WebSockets, Server-Sent Events, Comet and Server Push (HTTP1 and HTTP2) are all protocols to do that. There have been many Ruby implementations of these. Good old AJAX was probably the first widespread attempt. I'm sure there are some I missed. It's been the "near future" for as long as there's been a present.

Do you already know why we want WebSockets, and how bad most solutions are? Scroll down to "ActionCable and…

RubyMine Blog 

RubyMine 2018.2.1: Bug-fix Update

Hi everyone,

RubyMine 2018.2.1 (build 182.3911.41) is now available. This build provides a number of bug-fixes for the recently published v2018.2:

  • Fixed the inability to run Cucumber and RSpec tests on Windows [RUBY-21906], [RUBY-22232]
  • Fixed console output for programs using the TERM variable [RUBY-22220]
  • Other bug-fixes

See the release notes for the full list of improvements, and please report any issues you encounter.

Download RubyMine 2018.2.1

Your RubyMine team

The Bike Shed 

166: Are Services the New Rewrite?

Chris & Derek discuss the world of services, exploring the various forms SOA can take, the oft stated benefits, and some of the pitfalls they commonly see in the wild. The discussion ranges from alternative architectures, guidelines for how to think about services within your platform, and even includes an anecdote about thoughtbot's foray into the world of SOA on Upcase.

Awesome Ruby Newsletter 

Issue 116 - Guys, REST APIs are not Databases


How to configure RSpec in Ruby on Rails

Article for Junior developers on how to set up: Rails 5.2, RSpec 3.7, Factory Bot, Database Cleaner

Article was written 2018-08-09 and applies for current versions of gems

Configure fresh project

I’m assuming the reader has set up Ruby and Ruby on Rails on his computer after reading book Agile Web Development with Rails or

We are going to generate fresh Ruby on Rails project withot the native Ruby on Rails tests.

To display all options for fresh project you can lunch:

rails new -h

To generate fresh new project without Rails tests we will run:

rails new my_rspec_project_name --skip-test

Next open the Gemfile with your editor …

Junior Developer 

Safer JSON munging

At work we have an ETL process where we get a CSV from a partner and put it in a database as JSON. Sometimes the column names are a little off and we have to rename things. Also, sometimes we need to derive new values from the data we've imported, and sometimes we delete some of the unnecessary key/value pairs. So basically there's a good bit of munging going on there.

Initially I was writing little one-off scripts to do this stuff. For each record, grab it, munge the JSON, save it. But that was kind of stressful since I was always one typo away from messing up the data and having to re-import or restore from the audit records. Unit tests help, of course, but having to write a new…


Junior Developer Set Up Rails With Rspec Factorybot Database Cleaner

How to configure RSpec in Ruby on Rails

Article for Junior developers on how to set up: Rails 5.2, RSpec 3.7, Factory Bot, Database Cleaner

Article was written 2018-08-09 and apply for current versions of gems

Configure fresh project

I’m assuming the reader has set up Ruby and Ruby on Rails on his computer after reading book Agile Web Development with Rails or

We are going to generate fresh Ruby on Rails project withot the native Ruby on Rails tests.

To display all options for fresh project you can lunch:

rails new -h

To generate fresh new project without Rails tests we will…

GoRails Screencasts 

Affiliate & Referrals Programs with Stripe & Rewardful

Easily add an affiliate or referral program to your Rails application using Stripe and Rewardful
Ruby Weekly 

Changing the Way Ruby Creates Objects

#411 — August 9, 2018

Read on the Web

Ruby Weekly

Visualizing Ruby Execution — The author of VisualizeRuby has added the ability to generate an image of the execution path for a given application run, though it’s still early days and may not run on all code.

Dustin Zeisler

Changing the Way Ruby Creates Objects — Tapping into Ruby’s metaprogramming to change the way a class (and its subclasses) create objects. Messing around with the way that Ruby creates objects can occasionally be educational, interesting, or useful, and usually in that order ;-)

Benedikt Deicke

Be the First to Try Powerful…


Malicious ruby gem - active-support


The missing piece for using private gems

If you have multiple projects and want to re-use code between them, extracting the shared code into gems and hosting them on a private gem server is a common pattern.

You goal is to avoid copy-and-pasting the same stuff over and over again. But you also want to make sure all projects are using the same version of a thing. Be that library code, assets, higher level components or tooling configs. A private gem is an easy way to achieve this, while also making your code smaller and easier to understand.

The annoying part

The workflow to keep everything aligned has been a bit annoying so far. Packaging and publishing your private gem is easy enough, but now you want to make sure all projects…

Ruby Pigeon 

Dependency Injection Containers vs Hard-coded Constants

Dependency injection (DI) is a somewhat contentious topic in the Ruby community. Some argue that DI containers are unnecessary complexity cargo-culted from Java. Some argue that DI is the path to cleaner, simpler, more-testable code.

In this article, I want to compare and contrast two approaches: hard-coded constants versus using a DI container. The difference might not be as big as you think!

Let’s start with a quick explanation of DI, and DI containers.

What Is A Dependency?

A dependency is some external object that is relied upon. Take this module, for example:

module RegisterUser
    if UserValidator.validate(params)

UserValidator and UserRepository are both dependencies of RegisterUser

What Is Dependency Injection?


All Ruby Podcasts by 

RR 374: Ruby 2.5 Enumerable Predicates Accept Pattern Argument WITH Prathamesh Sonpatki


  • Charles Max Wood
  • David Richards
  • Eric Berry
  • Dave Kimura

Special Guests: Prathamesh Sonpatki

In this episode of Ruby Rogues, the panel talks to Prathamesh Sonpatki about Rails 5. Prathamesh works for BigBinary, where they publish a lot of blog posts on things like Ruby, speaks at conferences and is the organizer of RubyConf India. They talk about the biggest changes that have occurred from the new Rails 5 release, CISM tests, and the struggle that testing brings. They also touch on different testing approaches, especially in Rails 5, Capybara tests, and more!

In particular, we dive pretty deep on:

  • Prathamesh intro
  • What have you been doing with Rails 5?
  • What have you…
All Ruby Podcasts by 

MRS 055: Nadia Odunayo

Panel: Charles Max Wood

Guest: Nadia Odunayo

This week on My Ruby Story, Charles talks to Nadia Odunayo. Nadia was previously on Ruby Rogues Episode 264 and she used to have her own podcast called Ruby Book Club. She first got into programming because when she was in college she launched a creative writing publication and she was frustrated that she had to keep asking others for help. This was when she started researching coding and how it all worked so that she could put her ideas into action. They talk about Ruby being the first programming language she learned, the importance of learning both the frontend and the backend, her desire to run her own thing, her need to find a company that…



Announcing Hanami v1.3.0.beta1

Hello wonderful community!

Today we're happy to announce v1.3.0.beta1 release 🙌 , with the stable release (v1.3.0) scheduled for October 2018.

Release 😻

The 1.3 series is a preparatory work for 2.0.

We care a lot about Semantic Versioning and to make the upgrade as smooth as possible for the next major release. This is why we took the change to focus only on stability and to introduce enhancements to ease the upgrade.

RSpec is the new default testing framework 🏆

Back in the days, when I started Hanami (which used to be known as Lotus), the choice about the default testing framework fell on Minitest because it's lightweight…


The Ultimate Guide to HTTP Requests in Ruby

If you’d like to get information from a website, or if you’d like to submit forms, upload files… …you’ll need to send an HTTP request & then process the response. In this article you’ll learn how to: Make a simple HTTP request using net/http Send SSL requests Submit data using a POST request Send custom […]

The post The Ultimate Guide to HTTP Requests in Ruby appeared first on RubyGuides. Don't miss your free gift here :)

Greater Than Code 

092: A11y Ally with Rob DeLuca

In this episode, Rob DeLuca talks about ambition, designing and testing for accessibility on the web, hard problems vs squishy problems, and moving from a developer role into a bussiness-y roll within a company.
Dustin Zeisler 

Visualize Ruby Execution


In my last post, I showed how Ruby code could be transformed into a flowchart using static analysis, which is done with the gem VisualizeRuby. Building upon that I’ve added the ability to show the execution path on the flowchart. It highlights each corresponding node for each line of code executed. For building flowcharts with Ruby code I’ve got a neat demo page, but to add the execution path to this demo would be a security issue, see remote code execution vulnerability. Since there is not an easy way to make that happen safely, you’ll have to follow along at home on your own computer’s.

Follow the installation instructions on github

Let’s talk about a use case for this. I used to…

Riding Rails 

Rails 5.2.1 has been released!

Hi everyone,

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

CHANGES since 5.2.0

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

Full listing

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


If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256 hashes.

Here are the checksums for 5.2.1:

$ shasum -a 256…
bogdanvlviv / Bogdan 

References to changes in Rails 5.2

This post is a collection of references to some changes that were done during the development of Rails 5.2.

Read What is new in Rails 6.0

Start Rails 5.2 development

Prevent double firing the before save callback of new object when the parent association saved in the callback

Fix inconsistency with changed attributes when overriding AR attribute reader

Fix ActiveModel::Errors #keys, #values

Fix migration tasks

Fix destroy with locking_column value null

Fix ActiveRecord::Persistence#touch with locking

Set consistent typecast ENV[“VERBOSE”]

Improve the upgrade path of Strong Parameters

Define path with __dir__

Use respond_to test helpers

Keep INNER JOIN when…


Convert string “true” and string “false” to boolean with Rails

Rails 5't')     # => true'true')  # => true    # => true'1')     # => true'f')     # => false'0')     # => false'false') # => false   # => false     # => nil


Rails 4.2


Ruby Magic by AppSignal 

Changing the Way Ruby Creates Objects

One of the things that makes Ruby great is that we can customize almost anything to our needs. This is both useful and dangerous. It’s easy to shoot ourselves in the foot, but when used carefully, this can result in pretty powerful solutions.

At Ruby Magic, we think useful and dangerous is an excellent combination. Let’s look at how Ruby creates and initializes objects and how we can modify the default behavior.

The Basics of Creating New Objects from Classes

To get started, let’s see how to create objects in Ruby. To create a new object (or instance), we call new on the class. Unlike other languages, new isn’t a keyword of the language itself, but a method that gets called just like any…

BigBinary Blog 

Ruby 2.6 Introduces Dir#each_child and Dir#children instance methods

This blog is part of our Ruby 2.6 series. Ruby 2.6.0-preview2 was recently released.

Ruby 2.5 had introduced class level methods Dir::each_child and Dir::children. We wrote a detailed blog about it.

In Ruby 2.6, same methods are added as instance methods on Dir class. Dir#children returns array of all the filenames except . and .. in the directory. Dir#each_child yields all the filenames and operates on it.

Let’s have a look at examples to understand it better.


directory ='/Users/tejaswinichile/workspace')

=> ["panda.png", "apple.png", "banana.png", "camera.jpg"]

Dir#each_child iterates and calls block for each file entry in the given…

Sam Saffron 

Finding where STDOUT/STDERR debug messages are coming from

Often in development we have an annoying message in our console that we simply can not find the source of, here is a little trick you can use to hunt messages like this down.

Recently, we have been experiencing “stalls” in the Puma web server in development, this means that quite often during our dev cycle we would hit CTRL-C and be stuck waiting many many seconds for Puma to stop. Sometimes needing to fallback to kill -9 on the Puma process.

We definitely want this Puma issue fixed, however our “web application server of choice” is Unicorn not Puma. It makes little sense for us to run Puma in development. Our Unicorn configuration is very mature and handles all sorts of magic including…

BigBinary Blog 

Ruby 2.6 adds option to not raise exception for Integer, Float methods

This blog is part of our Ruby 2.6 series. Ruby 2.6.0-preview2 was recently released.

We can use Integer and Float methods to convert values to integers and floats respectively. Ruby also has to_i and to_f methods for same purpose. Let’s see how it differs from the Integer method.

>> "1one".to_i
=> 1

>> Integer("1one")
ArgumentError: invalid value for Integer(): "1one"
	from (irb):2:in `Integer'
	from (irb):2
	from /Users/prathamesh/.rbenv/versions/2.4.0/bin/irb:11:in `<main>'

The to_i method tries to convert the given input to integer as much as possible whereas the Integer method throws an ArgumentError if it can’t covert the input to integer. The Integer and Float methods parse…

Appfolio Engineering 

How Can I Use Ruby 2.6 JIT?

I gave a talk on using JIT in Ruby 2.6 at Southeast Ruby - a great regional conference with a very friendly, cozy vibe. If you get a chance, I highly recommend going next year! It'll be August 1st and 2nd, 2019.

Wondering about what JIT is, how it works and why you'd use it? Or how to try it out in (currently pre-release) Ruby 2.6? Here are my slides. Don't miss the presenter notes, which have extra detail beyond just what's in the slides.



Factory Bot trait for attaching Active Storange has_attached

How to add Active Storage attachement as a Factory Bot (or Factory Girl) trait.

technology used in the example: Rails 5.2.0, Ruby 2.5, Factory Bot 4.10, RSpec 3.7

# app/models/account.rb
class Account < ActiveRecord::Base
  has_attached :image

# spec/rails_helper.rb
FactoryBot::SyntaxRunner.class_eval do
  include ActionDispatch::TestProcess

# spec/factories/accounts.rb
FactoryBot.define do
  factory :account do
    name 'Tomas'

    trait :with_avatar do
      avatar { fixture_file_upload(Rails.root.join('spec', 'support', 'assets', 'test-image.png'), 'image/png') }

make sure you have test image to spec/support/assets/test-image.png

Now you can do:

Ruby on Tales from a Codemancer 

Ruby 2.5 adds KeyError#receiver and KeyError#key

Ruby 2.5.0 was recently released. Earlier to Ruby 1.9 Hash#fetch method would raise IndexError for an invalid key. An IndexError is raised when the given index value is invalid. irb(main):001:0> hash = { 'foo' => 'bar' } irb(main):002:0> hash.fetch('foo') IndexError: key not found from (irb):2:in `fetch' from (irb):2 from :0 KeyError class was introduced in Ruby 1.9 and it inherits from IndexError class. It is raised when the specified key is not found.
Drifting Ruby Screencasts 

Improving Partial Loading Performance

N+1 queries can make an application slow. Having queries called within views can also slow down an app as well as making it less extendable.
Ruby Together News 

July 2018 Monthly Update

Hello! Welcome to the monthly update. During July, our work was supported by Coinbase, Cloud City Development, reinteractive, and many others.

ruby together news

In July, Ruby Together was supported by 74 different companies, including Sapphire member Stripe. In total, we were supported by 79 individual members and 66 friends of Ruby Together. Thanks to all of our members for making everything that we do possible!

The Ruby Together Board of Directors met, and was able to finalize and ratify a plan for a new Ruby open source mentorship program called RubyMe--stay tuned for an official announcement with more details!

In community news, Developer Evangelist PJ Hagerty continued to spread…

RubyGems Blog 

July 2018 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 in July. news

In July, we updated 15 dependencies in, and we released the alpha version of two-factor authentication for logging into the website. If you’d like to try it now, enable it by running document.cookie='mfa_feature=true;path=/' in your browser console. We’re working on adding support for multiple factors to the CLI as well, and you should see more updates on it next month. We also fixed a few small bugs around the dashboard and Atom…

This month, gained…

Julia Evans 

New zine: Bite Size Command Line!

I released a new zine last week! It’s called “Bite Size Command Line”, and it’s explains the basics of a bunch of Unix command line tools! I learned some useful new things by writing it, and I hope you do too. You can get it for $10 at It’s the sequel to Bite Size Linux which I released in April.

If you want to get an idea of what’s in it, I’ve been posting the work-in-progress comics along the way on Twitter. You can see some of them on Twitter here.

Here’s the table of contents:

why I’m excited about this zine

Originally when I started working on this, I kind of didn’t think it was that exciting – I thought “whatever, I know command line…

Riding Rails 

Rails 5.2.1.rc1, faster parallel testing and more

Hello everyone! This is Roque, with the latest news about Ruby on Rails!

Help test Rails 5.2.1.rc1

Help us test this release candidate to have a solid and stable 5.2.1.

Faster parallel testing

Instead of running database migrations for each set of tests, Rails will load the schema to improve performance.

Raises exception when respond_to is called multiple times

An exception will be raised when respond_to is called multiple times in an incompatible way. For example, when the Content-Type values do not match.

Set a default Content-Type for the method head

The method head will have Content-Type as text/html when one is not provided.

Fix the IP address logged by Rails

It will now log…

Andy Croll 

Delegate to simplify your code

One way of thinking about object-oriented programming is as passing messages between objects.

In many cases you may want to surface a public method on a associated object as if it was a method on the original object.

The two main ways to do this are:

  • the Forwardable functionality in the the Ruby Standard Library, documentation here.
  • the delegate method, an Active Support core extension (available if you’re using Rails) documentation here.

Instead of…

… creating new methods to call directly to associated objects.

# Plain Ruby
class Workspace
  attr_reader :user

  def initialize(user)
    @user = user

  def user_email

# Inside Rails
class Workspa…


…the Forwardable functionality…

Test Double | Our Blog 

The Three-Things Theorem of Function Intention

.grid { display: grid; grid-template-columns: 330px auto; } .grid-image { padding: 6px 20px 10px 0px; } @media (max-width: 700px) { .grid { grid-template-columns: auto; } }

orizuru: origami crane

Origami, the ancient art of paper folding, has gone through a modern mathematical renaissance. The folding process was originally passed down between generations orally. Recently, though, artists have developed a way to document the steps to fold a shape with a diagram called a crease pattern.

two colorability of bird base

New theorems have emerged to determine whether a crease pattern can be folded. For example, a crease pattern must be two-colorable. Each region in the…

A Theorem Proving Code Intention

We can think of our source files as crease patterns used to diagram the…

Honeybadger Developer Blog 

The Case of the Flaky Test Suite

In this story, Jason Swett of The Ruby Testing Podcast discusses the pitfalls of external dependencies in your test suites, and how to avoid them.
The Bike Shed 

165: The Tables Have Turned

Chris & Derek talk about beginnings and ends, borrowing from their consulting mindset for a conversation spanning CI, deployment, communication, team structure, and everything in between.


Back to the primitive. Testing with simplicity

In Ruby on Rails imagine that your controller is generating this JSON API:

# app/controller/users_controller.rb
class UsersController < ApplicationController
  def show
     @user = User.find(params[:id])

     render json: {
       href: user_path(@user)

This would generate JSON:

curl GET localhost:3000/users/123

  "name": "Tomas",
  "href": "/users/123"

Code samples are related to Rails 5.2 and RSpec 3.7

How would we test this ? Recently I’ve stumble upon a test that looks like this:

# spec/controllers/users_controller_spec.rb
require 'rails_helper'

RSpec.describe UsersController do
  describe 'GET show' do
    let(:user) {…
Drivy Engineering 

Implementing Up Navigation on Android

Parent Navigation has always been a tough topic on Android. There are not a lot of apps that implement the guidelines correctly, maybe because they are hard to understand or complicated to implement. Even the Google apps don’t implement them: it’s always frustrating to take a screenshot, press Up on the preview and not be redirected to the Google Photo app 😞.

Unlike the Back button, which should come back to the previous screen – even if that screen was not from the same app –, the Up button should stay in the same app.

Let’s see how to implement this navigation.

A Simple App

Here is a simple music app, with 3 activities:

  • a Main activity, with a list of albums
  • an Album
Awesome Ruby Newsletter 

Issue 115 - TIL: You can define your gem dependencies inline with bundler, which is amazing for small scripts

Ruby Weekly 

Matz on Ruby's past, present and future after 25 years

#410 — August 2, 2018

Read on the Web

Ruby Weekly

▶  Matz on Ruby After 25 Years — The creator of Ruby (Yukihiro ‘matz’ Matsumoto) reflects on Ruby’s past and looks to its future in the shape of Ruby 3.0.

Yukihiro Matsumoto

Stop Shipping Untested Ruby Code with Undercover — Get coverage warnings on changed files so you can be sure your new code is covered while working on that legacy code base.

Jan Grodowski

Long Term Support for Rails 2.3 and 3.2 — Rails LTS provides security patches for old versions of Ruby on Rails. Currently Rails 2.3 and Rails 3.2 are supported.

Rails LTS sponsor

rails - Sips & Bits by 

Keep your API in shape with API Blueprint

Keep your API in shape with API Blueprint

When you are starting a new API project with Rails your first question might be: should you do it using GraphQL or just go with a good old REST API.

After much consideration, you decide to go with a REST API? Good! Continue reading this post.

Now, before you begin to consider how to implement your API, your main concern should be how to keep your API documentation up to date. This is something that always creates a sort of tension in projects where the team have to go through many hoops to keep code and docs in sync.

In a recent project, I was looking for a solution that could be easily integrated into our Rails application and at the same time allow the team to write the API definition…

The Life of a Radar 

Web Directions Code Leaders: Hiring Juniors

Here are my raw speaker notes for my Web Directions Code Leaders talk, titled "Hiring Juniors". The video will be online later.

The slides for this talk are available here on Speakerdeck



Hi, I'm Ryan. You know that part already. What you might not know is that I've been mentoring juniors on-and-off for close to a decade now and I've had varying rates of success.

I've mentored juniors who have gone on to become lead developers at tech companies you'd probably know about.

But, at the same time, I've also mentored juniors that have quit the industry altogether.

Recently, I've spent about the past 10 months recruiting, hiring and training up juniors as a part of the Culture…

Passenger - Phusion Blog 

Passenger 5.3.4: fixes crash on startup for BSD

Passenger 5.3.4: fixes crash on startup for BSD

Version 5.3.4 of the Passenger application server for Ruby, Node.js, Meteor and Python has been released. This release contains fixes for a bug that crashed Passenger on BSDs, as well as the handling of chunked bodies when PassengerBufferUploads is off.

Startup crash on recent BSD versions

Some users reported that Passenger was crashing on the most recent releases of OpenBSD and FreeBSD. Hongli tracked the problem down to the way that we check if Boost function pointers are empty or not, and fixed the regression. At the same time Boost was updated to the latest release, or: version 1.67.0.

Chunked uploads when Passenger buffering is off

Fixes the handling of HTTP requests with chunked…

All Ruby Podcasts by 

MRS 054: Mark Locklear

Panel: Charles Max Wood

Guest: Mark Locklear

This week on My Ruby Story, Charles talks to Mark Locklear. Mark first got into programming when there wasn’t a lot of opportunities for him to continue to work in quality assurance and he decided he wanted a change of career, so he went to community college to learn programming. They talk about how he was first exposed to Rails, where he is working currently, and what was it about Rails that got him excited. They also touch on what made him want to move from quality assurance, how he mentors his students at the community college, and more!

In particular, we dive pretty deep on:

Jekyll • Simple, blog-aware, static sites 

Sponsoring Jekyll’s development

(TL;DR: We’re open for sponsorships on our OpenCollective page)

Hi Jekyllers,

As you may know, Jekyll is a completely free and open source project. We offer our software and its related plugins and documentation at no cost because we believe that good software should not cost anything. We’re not planning on changing that, but today I want to talk about a different monetary aspect of open source.

Open source developers being paid for the work they do is a rare sight. Most open source software is effectively the result of hundreds and thousands of hours of free labor provided by individuals who are passionate enough to work outside of their day job to create software that, ironically, is…

Martian Chronicles, Evil Martians’ team blog 

Lean by design: 5 wins for one product

Author: Irina Nazarova, Account Manager at Evil Martians

See how we turned the tables on product development process at when the project was challenged to scale. Learn how putting a designer in charge and borrowing from Lean software development handbook can help ease product’s growing pains.

For the past two years, we have been working with eBay on, a startup that helps sellers outside the US scale their businesses across borders. While we were still in the MVP phase, running product development was a breeze. Sticking to Agile Manifesto kept us covered: we prepared designs, built features and released them in quick iterations while collecting customer feedback…


Greater Than Code 

091: Solving Puzzles and Productive Failure with Kim Vanderspek

In this episode, Kim Vanderspek talks about solving puzzles and teaching others to do the same by using technology to visualize math by quilting, sewing, Playdough, and other mediums. She also explains why failure is an important part of success, and why perseverance matters over content.
All Ruby Podcasts by 

RR 373: Super Good Software/Stembolt Technologies - Understanding Your Production Apps with Jared Norman


  • Charles Max Wood
  • David Richards
  • Eric Berry
  • Catherine Meyers
  • Dave Kimura

Special Guests: Jared Norman

In this episode of Ruby Rogues, the panel talks to Jared Norman about understanding your production apps. Jared has been programming since he was about 10 years old and for the past 7 years, he has been doing Ruby. These days, he runs a consultancy company called Super Good Software doing Ruby on Rails stuff and mostly eCommerce. They talk about his article You Can’t Save Everyone: Some Exceptions Should Be Left Alone, when capturing exceptions is the right way to go, developing with good visibility in mind, and more!

In particular, we dive pretty deep on:

  • Jared intro
Kevin Sylvestre 

Building a Testing Framework Similar to RSpec in Ruby

A guide to building and understanding a testing frameworks like RSpec
BigBinary Blog 

Ruby 2.6 adds option to not raise exception for Integer, Float methods

This blog is part of our Ruby 2.6 series. Ruby 2.6.0-preview2 was recently released.

We can use Integer and Float methods to convert values to integers and floats respectively. Ruby also has to_i and to_f methods for same purpose. Let’s see how it differs from the Integer method.

>> "1one".to_i
=> 1

>> Integer("1one")
ArgumentError: invalid value for Integer(): "1one"
	from (irb):2:in `Integer'
	from (irb):2
	from /Users/prathamesh/.rbenv/versions/2.4.0/bin/irb:11:in `<main>'

The to_i method tries to convert the given input to integer as much as possible whereas the Integer method throws an ArgumentError if it can’t covert the input to integer. The Integer and Float methods parse…

Scout ~ The Blog 

Monitoring Django apps on Heroku

I don't know of an easier way to deploy a Django app than letting Heroku do the work. That said, how do you stay on top of your app's performance, errors, and stability post-launch? Running an app on Heroku is a blissful experience, but it presents some monitoring challenges that aren't present when you control the hardware.

In this post, I'll walk through a free-to-start, low-effort approach that gives you great visibility of the health of your Django app on Heroku. All of the services below either have Django-specific support or don't require a significant time investment to work with a Django app.

Focus Service UptimeUptime Robot Application Performance MonitoringScout Lo…
Test Double | Our Blog 

Complex FFI with Rust & Unity

As promised in "Getting started with FFI: Rust & Unity", the next steps for any FFI binding is a "zero-copy" bridge for complex data types. In other words our current goal is to pass classes, objects, or structs between the two languages. Though a binding between Rust and Unity is beneficial in and of itself, I want to go another step further, and show the way to approach this given any pair of languages.

NOTE: If you have not read the original post, please do that first. We'll be building off of those concepts here.

The finished project

Just as we did the first time, the results of this work can be found on GitHub. The finished project is a simple app that synchronizes the position of…

GoRails Screencasts 

Batching Backgrounds Jobs with Sidekiq

Sidekiq Pro or sidekiq-batch lets you run a set of background jobs in parallel and then a callback once they're finished. This is perfect for building more advanced workflows for your background jobs in Rails.
Notes to self 

Firefox needs some more RAM to run your Rails system tests

A quick fix for an annoying (and not very descriptive) error Browsing context has been discarded when setting up Ruby on Rails system tests with Firefox headless.

Here is how that might look like:

Selenium::WebDriver::Error::NoSuchWindowError: Browsing context has been discarded
test/system/public_pages_test.rb:7:in `block in '

Selenium::WebDriver::Error::UnknownError: Failed to decode response from marionette


Selenium::WebDriver::Error::SessionNotCreatedError: Tried to run command without establishing a connection
Riding Rails 

Rails 5.2.1.rc1 has been released!

Hi everyone,

I am happy to announce that Rails 5.2.1.rc1 has been released.

If no regressions are found, expect the final release on Monday, August 6, 2018. If you find one, please open an issue on GitHub and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

CHANGES since 5.2.0

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

Full listing

To see the full list of changes, check out all…

Riding Rails 

Better instrumentation, enhanced Postgres helpers and more

Hello from London! The heatwave is finally over and we can get back to 🌧. This is Kir, bringing you the latest Rails updates.

Add cpu time, idle time, and allocations features to log subscriber events

The change makes it much easier to instrument CPU time and object allocations with ActiveSupport::Notifications events.

Prefer rails command over bin/rails

In some files we recommended using rails, in others bin/rails. The inconsistency is now fixed 🎉

Why prefer rails as the recommended executable? It does all the heavy lifting of dispatching to the app appropriate Rails version, so that’s why users don’t need to target bin/rails manually.

PostgreSQL 10 new relkind for partitioned tables

Ruby on Tales from a Codemancer 

Ruby 2.6 added options to Exception#full_message

Ruby 2.6.0-preview2 was recently released. Ruby 2.5.0 The Exception#full_message method returns a formatted string of the exception. >> e ='foo') => #<StandardError: foo> >> e.full_message => "\e[1mTraceback\e[m (most recent call last):\n(irb):14:in `full_message': \e[1mfoo (\e[1;4mStandardError\e[m\e[1m)\e[m\n" The string contains escape sequences too. It was proposed that escape sequences should be excluded from the error message. Nobuyoshi Nakada said that since Exception#full_message is expected to return the message printed to stderr, escape sequences are intentional.
Karol Galanciak - Ruby on Rails and Ember.js consultant 

Trolling In Ruby - Implementing JavaScript-like Maths With Implicit Conversion Hijacking

If you’ve ever worked with JavaScript, especially in pre-SPA/pre-frameworks era with just jQuery, you probably had a chance to see an “exotic” maths in action that looks similar to this:

"3" + 4
// => "34"

That kind of behavior usually comes as a big surprise and due to that fact, JavaScript has gotten some bad reputation (even though there is a rationale behind it). If we tried that in Ruby, we would get an obvious TypeError:

"3" + 4
# => TypeError (no implicit conversion of Integer into String)

Would it be possible though to obtain the same result somehow in Ruby?

Explicit Conversion vs. Implicit Conversion

The answer is yes! But before we get to the actual…

Ruby Magic by AppSignal 

Ruby Magic Summer Special: The Best of AppSignal Academy

Remember when you were a kid, and you bought those omnibus double edition comics? How magical reading them was? We won’t pretend this will be as unforgettable, but we do think we’ve put together a nice extra-chunky Best-of AppSignal Academy selection for you to read at the beach, the park, or just on a lazy Sunday, that will absolutely make your day.

Here are our top 5 hammock reads:

Custom Exceptions in Ruby

Almost everything in Ruby is an object and errors are no exception. #dadjokes

Ensuring Execution, Retrying Failures and Re-raising Exceptions in Ruby

Besides rescue, Ruby has more ways to handle exceptions. We’ll use the retry and ensure keywords as well as reraised exceptions to…

The Bike Shed 

164: A Piece of My Identity

Awesome Ruby Newsletter 

Issue 114 - My favorite parts of Ruby


Insufficient URI encoding in restforce

Appfolio Engineering 

Can I Use Ten 10% Speedups to Make Ruby Instant?

There are a lot of little speedups to Ruby around. I write about a bunch of them. It wouldn't be too hard to collect 100% worth of little 3% and 5% and 10% speedups. Presumably it won't make every Ruby program instant, but what would it do? Heck, Ruby has had way more than ten big speedups over the years. Shouldn't Ruby be instant right now?

Let's talk about how you do performance math - how you check those improvements and how they add up. Then when you find speedup in the wild, you can guess a little about how much they'll help you.

Why Rockets Explode On The Launchpad

When I was a kid, we did a math exercise in class. NASA has a hard job because rockets are complicated. Each piece of a… 

[Off-Topic] The Pity Evolution of Modern Society

The world is perishing in an orgy of self-righteousness.

People from Wisecrack always manage to put a smile on my face. They give me hope that there are still people of reason in this world. This essay is inspired by that video and the gathering of complementary thoughts.

As an engineer I always find myself baffled by what we are able to create. As an engineer, no one could ever think that one of the most fabulous creations of humankind, the internet, and it's most successful streak of hits - ubiquitous mobile access and social networks that can gather a considerable amount of people at the same time - could ever be used as weapons of mass destruction.

Far from the only instance of…


Ruby on Rails Active Storage how to change host for url_for

Given you use Rails 5.2 Active Storage for file uploads

# app/models/account.rb
class Account < ActiveRecord::Base
  has_one_attached :avatar

# rails console
a = Account.create
a.avatar.attach(io:'/tmp/dog.jpg'), filename: 'dog.jpg')

by default the url for active storage is set to

# rails console

# => "" 

# => "" 

To change the host name:

# config/environments/developent.rb
Rails.application.routes.default_url_options[:host] =…
Ruby Weekly 

A Look at Ruby's Global Method Cache

#409 — July 26, 2018

Read on the Web

Ruby Weekly

Pundit 2.0 Released: The Pure Ruby Authorization Library — The extremely popular ‘minimal authorization’ library reaches 2.0. Here’s the changelog.


Tweaking Ruby's Global Method Cache — The global method cache is one of the ways Ruby speeds up method lookups, so how much can we gain by tweaking its settings? (Hint: A little, but not a lot.)

Noah Gibbs

Ruby, Meet Rollbar — Detect errors in your production Ruby apps with our lightweight SDK, then debug them within minutes before your users notice. Get unlimited errors during your free trial.



Rails 5.2 credentials cheat cheat

Rails introduced “encrypted” credentials from Rails version 5.2:

In order to use Rails credentials you need to have master key in config/master.key or an environment variable RAILS_MASTER_KEY

In order to open the credentials file:

EDITOR=vim rails credentials:edit

# or master key as env variable
RAILS_MASTER_KEY=xxxxxxxxxxxxxxxx EDITOR=vim rails credentials:edit

Usage inside application code:

Fetch root value; e.g when credentials look like:

# ....
secret_key_base: yyyyyyyyyyyyyyyyyyyyyyyyy
# ....

RubyMine Blog 

RubyMine 2018.2 Released: Attach the Debugger to Remote Processes, chruby, YAML, and more

RubyMine 2018.2 (build 182.3684.86), the second major update this year, is now available! Learn about all the new features on our What’s new page, or you can read a brief summary below:


Download RubyMine 2018.2

Code insight

  • The upgraded Ruby type inference helps RubyMine understand the types of elements in blocks, arrays, and hashes better, which greatly improves the code autocompletion and navigation on the whole. More.
  • RubyMine now provides code insight (autocompletion, navigation) for models that use polymorphic associations. More.

Version managers

  • The new version features chruby and asdf support and makes all…
Running with Ruby 

Lenovo ThinkPad X1 Carbon (6th Gen / 2018) review – Sad story of a potentially great ultrabook

TL;DR – Don’t buy it

Don’t buy it. If you cherish your time and money and you think about a laptop as a work tool, go with something else.  There are many hardware problems with this computer and, if by any chance, you decide to open a warranty claim, Lenovo will make it really hard for you.

They will force you to send your laptop back (despite an on-site extended warranty), they will ship it back in an even worse state and will make you wait one more month to get a replacement.

Lenovo does not seem to have quality control in place. Here’s a list of problems you will likely encounter:

  • Not properly closing lid (a lot of space on one of the sides);
  • Overheating when connected to a docking…
All Ruby Podcasts by 

MRS 053: Jerome Hardaway

Panel: Charles Max Wood

Guest: Jerome Hardaway

This week on My Ruby Story, Charles speaks with Jerome Hardaway. Jerome used to be a panelist on Ruby Rogues and loved the ability to share his knowledge and interact with so many people from the community. He first got into programming by accident when he couldn’t find a job after becoming a veteran. He saw a commercial about job opportunities in coding, ended up finding a book on SQL and taught himself how to program. They talk about where he ran across Ruby on Rails, what he has worked on that he is particularly proud of, what he is doing currently, and more!

In particular, we dive pretty deep on:

  • Jerome’s experience being a panelist…
Search Results for “ruby” – via @codeship 

Using AWS EKS in Your Continuous Integration Workflow

Reading Time: 6 minutes

AWS recently rolled out EKS, and we’re excited to help you get started using it as part of your CI/CD process with Codeship.

What is EKS, though? It’s essentially AWS’s managed Kubernetes platform — but if you’re a little bit sick of hearing terms like “managed Kubernetes platform” all the time lately, we can take a minute here to unpack that in more detail.

“Get started using EKS as part of your CI/CD process with Codeship.” via @codeship
Click To Tweet

Defining EKS

EKS means you can run Kubernetes without directly managing any of the underlying machines running on your account that Kubernetes is running on — and without worrying about the setting-up-Kubernetes part…

Greater Than Code 

090: The Journey with Chelsea Troy

In this episode, Chelsea Troy joins the show to talk about measuring participation in meetings, cultivating questions kindly without assumption or judgement, and the problem with claiming to be “self-taught”.
Toxic Elephant 

No-one understands SemVer

I started reading this, and came upon this line:

Many people claim to know how SemVer works, but have never read the specification.

And I thought: Yes! This is exactly the problem. Everyone talks about SemVer, but no-one reads the specification, so the discussions don’t make sense. Finally, someone is going to Make Things Clear!

And then I read this:

Note: Stop trying to justify your refactoring with the “public but internal” argument. If the language spec says it’s public, it’s public. Your intentions have nothing to do with it.

What!? This person complains about people not reading the specifications, and then proceeds to contradict the very first article of the SemVer…

Julia Evans 

IP addresses &amp; routing

Hello! Tomorrow I’m running a workshop at work about the humble IP address, so here are some notes about IP addresses and how IP routing on Linux works!

This came up because someone on my team pointed out that there’s actually a LOT going on with IP addresses even though it seems like a simple concept, and they said they’d like to learn more. Here goes!

This post is only about IPv4 because I’ve still never used IPv6.

What’s in the IP header?

Almost every packet your computer sends and receives (with some exceptions like ARP packets) has an IP header.

There are 14 fields in the IP header. The only 3 important ones for most people to know about are:

  • the source IP address
  • the…
All Ruby Podcasts by 

RR 372: Hiring with Mindaugas Mozūras


  • Charles Max Wood
  • David Richards
  • Eric Berry
  • Catherine Meyers

Special Guests: Mindaugas Mozūras

In this episode of Ruby Rogues, the panel talks to Mindaugas Mozūras about hiring. Mindaugas is from Lithaunia and has worked at Vinted for the past 6 years, starting as a software developer and is now is the head of engineering there. They talk about why it’s hard to find great developers to hire, the importance of hiring both junior and senior developers, and his blog post A User Guide to Me. They also touch on how you come about writing up job roles, the importance of letting developers think outside of the box, and more!

In particular, we dive pretty deep on:

  • Mindaugas intro 

Now available: Master the Object-Oriented Mindset in Ruby and Rails

Back in late 2017 I set out on a little project to create a course of object-oriented design inspiration built around some of my favorite episodes from my show RubyTapas. As these projects so often do, it grew larger. Soon, it encompassed over 20 hours of brand-new video, pairing sessions, Q&A with industry luminaries, quizzes, supplemental readings, and more.

I initially released the course in beta form to just 300 students. Today, I'm happy to announce that Master the Object-Oriented Mindset in Ruby and Rails is available to all as a self-paced online course.

MOOM is a compilation of everything I've learned about writing flexible and comprehensible OO code over my two decades as a…

BigBinary Blog 

Ruby 2.6 adds Binding#source_location

This blog is part of our Ruby 2.6 series. Ruby 2.6.0-preview2 was recently released.

Before Ruby 2.6, if we want to know file name with location and line number of source code, we would need to use Binding#eval .

binding.eval('[__FILE__, __LINE__]')
=> ["/Users/taha/blog/app/controllers/application_controller", 2]

Ruby 2.6 adds more readable method Binding#source_location to achieve similar result.

=> ["/Users/taha/blog/app/controllers/application_controller", 2]

Here is relevant commit and discussion for this change.

Blog - Clean Code For Rubyists 

Clean code for your Ruby tests

 Writing unit tests is an important part of software development. Tests verify assumptions and protect against future breakage. It’s important to give our tests the love and attention they deserve. If your tests are hard to read, other developers won’t understand what you are testing. They will have difficulty finding gaps in your tests during pull request code reviews. Changes to the test code will likely result in further problems. What is the difference between a good and bad test? Let's look at some examples to find out.

Look at this Calculator class.

class Calculator
  def add(a, b)
    a + b

  def subtract(a, b)
    a - b

The class has two methods, add and subtract.…

Super Good Software 

Where The Wild Methods Are

Nearly all of the time when we’re methods in Ruby, we’re defining instance methods on some class or module. I bet nearly all of the method definitions in the applications you work on follow one of these forms:

class SomeClass
  def self.class_method()
    # Either you're defining a class method like this.

  class << self
    def other_class_method()
      # Or you're defining a class method like this.

  def instance_method()
    # Or you're defining and instance method like this.

Let’s ignore the first case for now; we’ll come back to it. The second two cases are really just the same. You’re defining an instance method on something.

As I…