cypriss / mutations

Compose your business logic into commands that sanitize and validate input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to autoload mutations in sub directory from scoped controller

RickCarlino opened this issue · comments

I have a controller inside of app/controllers/api/guides_controller.rb (it is namespaced as Api::GuidesController).

I have a mutation within app/mutations/guides/guide_update.rb as GuideUpdate (not namespaced).

When I try calling run() on the mutation I get an error for "uninitialized constant Api::GuidesController::GuideUpdate".

The quick fix for now was to make a mutations.rb file inside of initializers that does this:

Dir["app/mutations/**/*.rb"].each{|file| load file}

but this is probably a hack. Did I fail to follow a naming convention or something? It's for an opensource project, so feel free to take a look at the source code.

Thanks for maintaining this gem, it's one of the best I've seen in a while.

ActiveSupport::AutoLoad would expect to find that path namespaced under the
Guides module

Guides::GuideUpdate

And, as your friend, I would expect to see

Guides::UpdateGuide

But that is just a style issue

Thanks for the quick response. I will give it a shot tomorrow and close this issue now.
(Hilarious side note: I see from your profile you're from Barrington. I am writing this from Bloomingdale. Beer on me if I ever bump into you at a meetup)