Revisiting a Rails project from when I started developing, I wanted to figure out how to really DRY my controllers out—without making them unreadable by doing half/all of the work in a before_action
. (I've used CanCanCan's load_resource
in the past. That and some other gems I looked at are a little too DRY for what I want.)
So I wrote this module to encapsulate the business logic of finding the record and loading the params data within an Accessor
object. It's not meant to cover all cases, but I'm pretty happy with it.
I have it set up with controller tests in a scaffolded app here.