Jul 27, 2018

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 you’re going to add additional code into these directories, please have an application_thing.rb hanging out in root — treat it like every other class, less assets and views. Have everything inherit from that thing.

That’s not to say that subdirectories inside of these top-level directories should have an application_thing inside them. I’ll talk about my preference in another post.