Latest stories

My opinion on application_thing.rb vs base_thing.rb


I recently wrote about application_things and how having them will steer you into building more maintainable Rails applications. But I want to talk about going deeper. Let’s say you have a path of /my in your routes. /my has a lot of things, like a controller to manage credit cards, invoices, stuff like that. |- app |---controllers |------application_controller.rb |------my |...

Everything in your app directory should have an application_thing.rb


I haven’t written for a while so I thought I’d write something that has been bugging me. To maintain some sanity, it’s common (and rightfully fine) to have more than your standard 6 directories in your Rails app folder — you know, assets, controllers, helpers, mailers, models, views. The common ones are services, presenters, findersor queries, workers, things like that. If...

Introducing Setsy


There are a lot of gems to handle settings within your Ruby on Rails app. I’ve used Rails Settings Cached previously and I found it good for app-wide settings. I didn’t find it great for model-by-model settings. So I wrote Setsy, a Ruby gem for handling settings. Setsy is relatively simple but very effective library in handling settings on a model-by-model basis. I originally wrote...

Wrapping rendered collections into a layout without a file


You’ve probably done this: <%= render partial: 'product', collection: @products %> Maybe you want to wrap that product partial in <div class="col-sm-3"> on your home page, and <div class="col-sm-2"> somewhere else. Solution? Pass a local or set some sort of instance variable. Ew, right? There’s a little-known (at least, to me and the four people I spoke to) option to...

My ultimate life hack


Buy a take-and-bake pizza
Acquire and wield food scissors
Cut pizza into single, individual slice(s); set aside
Put any remaining pizza back into refrigerator
Cook the newly-cut pizza slices

Preventing online credit card fraud


In this post, I’ll go into detail on how to prevent online transaction card fraud by building a fingerprint of a user and doing some research (which any programmer can automate.) Some of these tips will be incredibly obvious, some of them won’t be so obvious. It’s a rather exhaustive and extensive process that can only be done manually if your transaction volume is low, but...

Cleaning up your icky ApplicationController


“Fat model, skinny controller” is a mantra. It’s a good mantra. But since `ApplicationController` is an abstract class, that’s not exactly easy (or good practice.) As the complexity of your application grows, you’ll find yourself in `application_controller.rb` quite a bit: adding methods and helpers for analytics, error handling, tracked events, roles/authorization...

What would the ideal service layer look like? (Part 1)


I’m a Ruby developer and I do a lot of stuff in Rails. Rails has a lot of things ready to go out of the box, but it really lacks a service layer, and while there are a few design patterns that lend themselves to having a more positive experience with service objects, there’s nothing that is very Rails-like. To get to this Rails-like service layer, we first need to understand what...

Creating a secure password the easy (and logical) way


Passwords are hard. My mom has had the same password since her first email account at work (90s). She used the same methodology for her password as she did my initial password. As someone who has spent time in the security field I’ve realized how important a secure password is, particularly when I have access to numerous admin-like credentials. Password managers are great, but sometimes...

How to not deal with donation fraud

H — a great company — recently published a blog post titled Stopping Sharon. It describes how they deal with and attempt to prevent “online donation fraud.” Quotes because “online donation fraud” makes it seem worse than it is: fraudulent transactions, most of the time from someone with a stolen credit card, are made to check the validity of a credit card. Preface:...