CategoryRails

Cleaning up your icky ApplicationController

C

“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)

W

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

It’s okay to love Ruby on Rails in 2017

I

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.

D

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

How I organize my Rails projects

H

After rails new comes a lot of decisions. Rails has great conventions but lacks documentation and in-house libraries for services, presenters, form objects. There’s also the debate about what to do with lib. Like most people, I have my preferred ways of doing things that serve me (and my clients) well. Admittedly, a lot of the inspiration for my ways of doing things comes from GitLab. Hats...