top of page

Rolify: Undefined local variable or method 'resourcify' for SomeClass

Recently I encountered an issue that may be tricky to debug for one not familiar with Rails and how it loads it's resources. The error would not just be tied to 'resourcify' as it also happened for the 'rolify' command within my User object. Furthermore, this isn't strictly tied to Rolify (Rolify actually has nothing to do with the error I was encountering, as you will see further down in the post) and it could be any other Gem that you've recently installed.


Upon installing a new gem for RBAC using Rolify, I attempted to spin up a Rails console. No problem here (although, some may receive an error just simply trying to spin up their console depending on their tech stack and/or Rails configuration), however once I attempted to access a class that utilized Rolify I received the error above (Undefined local variable or method 'resourcify'...).


All of my tests were passing, so I started digging deeper into the issue based on the current knowledge of installing a new Gem and the error. I figured a good place to start would be looking at the $LOAD_PATH variable. In doing so, I discovered that there wasn't any reference to 'rolify' as I would have expected since it was properly included within the project's Gemfile and bundle was successfully run and pulled in Rolify.


That was the piece of information I needed to "gently" remind me that we are using Spring as the application loader for my Rails application/API. As such, I had to run the bin stub for Spring in order to restart the server, upon which will properly load all of the dependencies of the new Gems installed.


Long story short, if you are using Rails Spring as an application loader, be sure to run spring stop prior to running your Rails console. Hopefully this post will help someone discover the issue sooner.


12 views0 comments
bottom of page