There Be Dragons: Rails Callbacks and Suppression

After a long hiatus from Rails, I found myself working in a Rails codebase this week. Here at Atomic, our recent focus has been on the wins provided by our starter kit. I still love Ruby and Rails, but after digging through a well-intentioned codebase, I was reminded how much I dislike Rails magic callbacks. Read more on There Be Dragons: Rails Callbacks and Suppression…

Make Monkey Patching in Ruby Less Risky with Refinements

Ruby makes it easy to extend its built-in classes, which can be very convenient and lead to more readable code—but it can also be dangerous. This practice, known as “monkey patching,” is common in the Ruby world, and since Ruby 2, it’s been possible to mitigate some of the risks using refinements. Read more on Make Monkey Patching in Ruby Less Risky with Refinements…

Phoenix Framework Support and Why Ruby on Rails Still Works

Functional programming has been successful through React and its derivatives on the front end. Why can’t we embrace it for the full stack? The solution for traditional model-template-view applications can be functional, too. A good incumbent is the Elixir language with Phoenix framework.
Read more on Phoenix Framework Support and Why Ruby on Rails Still Works…

Data with Rails and Ember CLI, Part 2: Building the Front End

In this post, we will finally be setting up the Ember front end to request data from the Rails back end we got up and running in my previous post: Data with Rails and Ember CLI, Part 1: Setting up the API. If you’ve already followed along with those steps, then you’re all set to get started here! Read more on Data with Rails and Ember CLI, Part 2: Building the Front End…

Data with Rails and Ember CLI, Part 1: Setting up the API

Earlier this year, I wrote a post about Getting Started with Rails and Ember CLI shortly after on-boarding onto my project. I didn’t originally plan on writing more tutorials with those technologies, but months after that guide was published, I received a comment asking if I would considering doing just that.

Read more on Data with Rails and Ember CLI, Part 1: Setting up the API…

Code Generation for Rails Utility Scripts

It seems that on every Rails project I work on, I end up writing utility scripts that make changes to the production data in some way or another. Perhaps it’s pre-loading hundreds of user accounts for a customer that wants to provide a spreadsheet of users, or populating an account with fake data that can be used for a demo, or manually fixing a data integration issue with an external system. Often, this requires parsing and processing a source file (like a CSV file). Read more on Code Generation for Rails Utility Scripts…

Active Record Aggregate Fields via Sub-Selecting Scopes

I was recently working on a piece of code from a legacy Rails application. An unusually large number of queries being run on a particular page let me know there was an N+1 query lurking.

The application was an online assessment platform dealing with assessments, questions, and responses. The question listing page was simply asking each question if it’s locked—which happens if it has any responses. So what’s the best way to query for lots of questions and their locked status? Read more on Active Record Aggregate Fields via Sub-Selecting Scopes…

Run a Local Rails Script on Heroku

Heroku provides a convenient command line interface for executing snippets of Ruby code remotely. One-liners can easily be piped into the heroku run console command. But what about much longer scripts that you write locally and want to execute in a remote Heroku environment? In this post, I’ll show you how to execute a long Ruby/Rails script in a remote Heroku environment.

Read more on Run a Local Rails Script on Heroku…

Rails, Active Record & Postgres – Optimizing Deletions

Every Rails project I’ve worked on has used Active Record. ORMs like Active Record have many benefits. They abstract you away from the database. They make querying data elegant and simple (in most cases).

However, sometimes Active Record is not more efficient than Postgres.
Read more on Rails, Active Record & Postgres – Optimizing Deletions…