Why You Should Avoid Models in Rails Migrations -- 10 Apr 2021
Humble Beginnings A simple Rails application exists with two models, Books and Authors. class Book < ApplicationRecord belongs_to :author end class Author < ApplicationRecord has_man...

Making RSpec Tests More Robust -- 19 Jul 2020
RSpec is a popular framework for testing Ruby code. With an expect assertion, a developer can make sure their code calls the proper method or an acceptable result is returned. The expect().to rec...

Ruby Processes and Threads - Configuring a Web Server -- 18 Jun 2019
Multiple popular Ruby web servers exist. Each Ruby application is different and the ultimate tl;dr for configuring a web server is: it depends. This post will not prescribe one web server or config...

Improving Remote Work as a Software Engineer -- 18 Feb 2018
After working in the Bay Area for many years, I decided that being able to afford a house was something I’d like to do. That and family led me back to the East Coast and a new chapter of my caree...

A Few RSpec Helpful Hints -- 12 Jul 2017
Two main frameworks dominate the Ruby testing world: Rspec and MiniTest. RSpec is a very expressive testing framework with many great features and helpers to make tests readable. When writing RSpec...

A Successful Year of Commits -- 26 Apr 2016
At Rails Conf 2015, I met a lot of great people from the Ruby community. These people had a profound effect on me, instilling in me a new motivation to become part of something larger than myself. ...

How to Diagnose Ruby on Rails N + 1 Query Problems -- 17 Apr 2016
Diagnosing performance problems in a production Ruby on Rails application can be deceptively complex. When constructing a new application or expanding the features of an existing one, development e...

Things to Consider when Metaprogramming in Ruby -- 10 Apr 2016
Metaprogramming in Ruby is a polarizing topic. The most common purpose of Ruby metaprogramming is for code to alter itself at runtime. Metaprogramming can be used to achieve terse and more flexible...

How to Deal with Timezones the Active Support Way -- 03 Apr 2016
“Well the code is bad because we had to…” is a phrase one might hear when discussing timezone offsets or daylight savings time considerations. Unless a developer is fortunate enough to work at a c...

Five More Active Record Features You Should Be Using -- 27 Mar 2016
In a previous post, I illustrated a few helpful ActiveRecord features. The entire API of ActiveRecord cannot possibly be contained within a single or even a handful of digestible posts; but, here a...

How to Build a Ruby on Rails Engine -- 20 Mar 2016
Ruby on Rails Engines are miniature applications whose purpose is to supplement a larger Ruby on Rails application. If functionality can exist independent from a main application, an Engine can pro...

The Power of Arel -- 13 Mar 2016
Many modern web applications have at least a few overlapping responsibilities. One of these responsibilities deals with maintaining state. A common choice for storing this state is by way of a rela...

The Real Cost of Technical Debt -- 06 Mar 2016
Writing software is an iterative process. Rarely is software written and then never revisited. When this iteration occurs, a software engineer is presented with multiple options. Usually, a single ...

Ruby Spaceship <=> Operator -- 28 Feb 2016
Adhering to the law of trichotomy, the <=> operator (sometimes called the “Spaceship Operator”) works by comparing two elements and returning a -1, 0, or 1. While the original mathematical cr...

Four PostgreSQL Tips -- 21 Feb 2016
PostgreSQL is an open source object-relational database used to power many production web applications. While many web applications interact with relational databases through Object Relational Mapp...

Ruby Threads and ActiveRecord Connections -- 14 Feb 2016
Processing large data sets is a common problem faced by many production web applications. One solution is to divide the work amongst multiple processes and have each responsible for a single or s...

How to Remove a Column with Zero Downtime in Ruby on Rails -- 07 Feb 2016
For a production Ruby on Rails application, uptime is paramount. Altering the structure of an application’s persistence layer is an operation that competes directly with uptime. Specifically, remov...

Nine Months of Commits -- 30 Jan 2016
It is hard to believe that already nine months have passed since the onset of my Year of Commits. In these past nine months, I have experienced a wide range of new aspects of open source developm...

Ruby Private Class Methods -- 24 Jan 2016
In the Ruby programming language, defined methods come in two variants: instance methods and class methods. Instance methods are available after an object has been initialized, creating an instan...

Contributing to Open Source in 7 Steps -- 17 Jan 2016
Making contributions to open source repositories is a great way to give back to the community. Open source software has a rich history and is a crucial component in many successful software applica...

How To Parallelize Ruby HTTP Requests -- 10 Jan 2016
It turns out that managing web requests is quite important when doing web development. A web application backed by an external or internal API can issue a lot of requests when rendering a seemingly...

Passages Rails Engine -- 03 Jan 2016
Routing in the Ruby on Rails world can, at times, be a tad confusing. The official Rails guide is very helpful for the basics; but, as an application grows, it can become hard to remember specific ...

Things I Wish I Knew When I Started Programming -- 27 Dec 2015
If by some magical event I could go back in time to the day before I started my first job as a software engineer, this is what I would say. Drive Slow I mentioned a similar message in a previous ...

Introduction to Rails 5 Attributes -- 20 Dec 2015
Shortly after the tenth anniversary of Ruby on Rails 1.0, Rails 5.0 Beta has been announced. While the main character of this release was without a doubt ActionCable, other really great features ha...

Ruby Refinements -- 13 Dec 2015
The Ruby language provides many powerful tools for software engineers to utilize. For instance, classes that have been previously defined and evaluated can be reopened and changed. This is commonly...

How to use Rails Strong Parameters -- 06 Dec 2015
In the latest major version of Ruby on Rails, Strong Parameters were introduced. The intent of this addition was to enable consistent and reliable parameter checking. Using Strong Parameters is sim...

Validates Type 2.0 -- 29 Nov 2015
One of the first projects that I worked on during this Year of Commits was validates_type. In case that name is too obscure, validates_type is a gem for validating that a specific value is exactly ...

How to Write Future-proof Mocks in RSpec 3 -- 22 Nov 2015
Tests are an important component in most software applications. Whether tests drive the development, or are strapped on after the fact, tests need to be reliable for future development to progress....

Five Active Record Features You Should Be Using -- 15 Nov 2015
Active Record is responsible for communicating with the persistence layer by default in Ruby on Rails applications. Using Active Record effectively and efficiently can greatly improve an applicatio...

Ruby DelegateClass -- 08 Nov 2015
Objects are a big deal in Ruby. A previous post about Ruby Objects can corroborate: Ruby Objects are pretty cool. There are many ways to work with Ruby Objects. Standard inheritance, module inheri...

Six Months of Commits -- 01 Nov 2015
Six months ago I started a challenge for myself. I wanted to contribute to open source software, a task that I had previously thought out of reach and intimidating. A plan that I had devised to o...

How to Traverse Foreign Ruby Code -- 25 Oct 2015
A Ruby on Rails project will most likely contain large amounts of third party software. Software written by other people can fluctuate greatly in terms of documentation. Even very well documented s...

Building a Simple Web Server with Ruby 2.0+ (Part 2) -- 18 Oct 2015
In a previous post, a very simple Ruby server was created to listen to HTTP requests. While great for a first step, this example server does nothing more than respond with “Hello World”. Greetings ...

Building a Simple Web Server with Ruby 2.0+ -- 11 Oct 2015
The Ruby language can be utilized for a variety of different purposes. The most popular of these is as a web scripting language. The entry point to these applications, the web server, is not someth...

Someone Wrote that Code on Purpose -- 04 Oct 2015
One of the great misconceptions of software engineering is the belief that “any code written in the past is probably wrong”. For some reason, an accepted mindset (usually among junior developers) i...

How to Create a Custom Enumerable -- 27 Sep 2015
Ruby is a wonderfully flexible language. An example of this flexibility is in the ability to define a custom collection class that acts as an Enumerable object. In Ruby, a collection that acts as a...

Just learn Rails (Part 3) HTTP status codes -- 20 Sep 2015
So you want to be a Rails superstar? To live large, big servers, requesting tars. Writing code all over the world, gotta make commits constantly. Great, I feel the same way. Assuming you have alre...

Rescue Groups Ruby Wrapper -- 13 Sep 2015
People need companions. We are a social species that enjoys surrounding itself with family and friends. But sometimes, and maybe more often than just sometimes, people crave companionship from some...

Stop and Take a Moment -- 06 Sep 2015
Someone in all our lives has offered up the advice: “Slow down”. It might have happened once or, if we are lucky, many people have said it. Regardless, the words did not sink in. At least not at ...

Active Support and Time -- 30 Aug 2015
If a list was compiled of useful Ruby libraries, Active Support would be close to the top. Based on the documentation alone, it is apparent that a very large amount of time went into thinking about...

I, Object! -- 23 Aug 2015
I am lucky enough to work with wonderfully talented people every single day. This is a guest post by one of my magnificent coworkers, Kristján Pétursson. Thank you for allowing me to share this kno...

Gems != Magic -- 16 Aug 2015
Ruby gems can seem magical. Usually, one (or more accurately: thirty) solution to a problem exists in the form of a gem. Using gems is easy and intuitive. Simply add a line in the project root’s Ge...

How to Process Large Data Sets with Ruby -- 09 Aug 2015
The need for data migrations in mature systems is real. At times, requests for these migrations can appear at random. One minute, a system is behaving as specified, happily fulfilling requests, and...

Faster Ruby Testing: Only Test What Matters -- 02 Aug 2015
Automated testing is important. Fast, exhaustive automated testing is even more important. Tests are responsible for ensuring the code you spend hours creating actually works. A great test suite ca...

Ninety Days of Commits -- 26 Jul 2015
It has been ninety days since I started the Year of Commits initiative. The criteria behind this challenge was to make a commit to a public Github repository every day. Technically, a commit like...

Just learn Rails (Part 2) -- 19 Jul 2015
In a previous post I explained how “just learning Rails” is not as straight forward as the phrase portrays. Even the novice programmer who learns Ruby on Rails in a methodical progression may still...

Create a Free Tech Blog -- 12 Jul 2015
The Internet is wondrous technology. If anyone remembers Geocities and Personal Home Pages, you can appreciate just how much the Internet has evolved. This evolution has recently enabled creating a...

Modules in Ruby -- 05 Jul 2015
Currently, one hundred percent of Year of Commits’ commits have been to Ruby repositories. Ruby has many strengths and is a very malleable language. Ruby can be written functionally or object orien...

Staying Motivated -- 28 Jun 2015
Motivation is the most important thing you can control. Only with proper motivation can one reach their full potential. A Year of Commits is a project that requires a decent amount of motivation. I...

Rails style subset validation -- 21 Jun 2015
Do you suddenly wake up in a cold sweat, wondering if there is finally a way to validate that your data is a proper subset that you desire? I too have experienced this horror, and that is why I mad...

You are not your code -- 14 Jun 2015
It may have been a mentor, a colleague, or even a random vagrant on your way to work. One of these people has been wise enough in to let you in on the well known fact that: “You are not your code”....

Short Feedback Cycles -- 07 Jun 2015
Forty-two days into my year of commits initiative has come and gone. With it, I have found some great processes for making my contributions efficient and effective. Feedback is extremely important ...

Writing good API wrappers -- 31 May 2015
Both in my day job and in my year of commits, I spend a lot of time thinking about APIs. For the uninitiated, an Application Program Interface (API) is an avenue for one piece of software to speak...

Contributing -- 24 May 2015
Since starting this 365 day adventure, I have done a mixture of contributing to my own projects and to others. At the on-set, I made an assumption that it would be an even distribution of commits b...

Just learn Rails -- 17 May 2015
Obligatory YoC update: Still going strong, 21 days in a row! The only real city I have lived in is San Francisco. I assume that in other cities, like New York and Los Angeles, people bring up topi...

validates_type -- 10 May 2015
In keeping with my apparent obsession with types, I created another helpful library: validates_type. I wanted a nice, lightweight way to assert that the types of my attributes are exactly what I ne...

Ruby Boolean -- 03 May 2015
Week one of my Year of Commits initiative is complete, 51 more to go. I did not plan on telling people about this until a few weeks into the task (in case history repeated itself and I gave up 20% ...

A Year of Commits -- 23 Apr 2015
Some people have no problem being motivated to be excellent every single day. I am not one of those people. While I love what I do, I think I can do better. It is very easy to make excuses for why ...