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:...

It’s okay to love Ruby on Rails in 2017


It’s okay to love Ruby on Rails for web development in 2017. There was a time when every third post on HackerNews was relevant to Ruby on Rails, if not Ruby. That time has passed. Does that mean Ruby on Rails is dead? No. Picking a language or framework is kind of like adopting: the older they are, they less cool they seem. Having said, Ruby on Rails is mature; it’s that older dog in the...

Does Ruby on Rails scale? Yes, yes it does.


Does Ruby on Rails scale? Yes, it does, and it does very well. To be more specific: Yes, it does. If someone told you it doesn’t scale, they haven’t been through the trenches. Those benchmarks you’re looking at are very skewed, too. The whole idea that “Rails doesn’t scale” admittedly started before my time with Rails, but it carries over today, though with little weight. These days, everyone’s...

So you want to learn Ruby. Here’s how.


Ruby is great. I love Ruby. Lots of people love Ruby. I’d argue that you’d be hard-pressed to find more Ruby die-hards than you would Python, PHP, or Go. Ruby is cool. Ruby is straightforward. Ruby is effortless. Ruby just makes sense most of the time[0]. Operating System Disclaimer If you’re on Windows 8 or older you’re going to have a bad time long-term. If you’re on Windows 10 you can probably...