While installing maquina-components in my project, I hit a NoMethodError for sidebar_open? . What started as “maybe I’m doing something wrong” turned into a deep dive into how Rails engines handle helpers, a wrong first fix, and eventually two PRs: one fixing a bug and another adding a feature.
The Bug
After running the install generator and adding the sidebar to my layout, I got:
undefined method 'sidebar_open?' for an instance of #<Class:...>
Enter fullscreen mode
Exit fullscreen mode
The generated MaquinaComponentsHelper had wrapper methods like app_sidebar_open? that delegated to sidebar_open? , but sidebar_open? lives in MaquinaComponents::SidebarHelper . That module was never included.
Why It Happens
Rails engines auto-include helpers from app/helpers/ , but only top-level ones.…