caprese icon indicating copy to clipboard operation
caprese copied to clipboard

Problem with controller scopes including underscores

Open le-martre opened this issue 6 years ago • 1 comments

Hello!

I have a small problem, my controllers are namespaced through a module like so

module MyApp class UsersController < ApplicationController

But then when I let the default Caprese actions, for example the index, I get this :

NameError (uninitialized constant MyApp::User)

So it seems Caprese searches in the controller scope for the User model. I looked in the code and saw that a function named unnamespace was supposed to remove these parts, at least that's what I got out of the method name?

When I implement the index function and insert a puts I can see that params[:controller] and unnamespace(params[:controller]) have the same values, in this case : my_app/users. But it could also be that unnamespace has nothing to do with that and that all of it is expected behavior :o

EDIT: After testing without the underscore, it works great! The problem is the underscore then I think :)

Thank you very much and have a great day!

le-martre avatar Jul 11 '18 14:07 le-martre

Interesting, I'll leave this open for when I can investigate further. I've never used a namespace that warranted an underscore, usually they are just API, or V1 , etc.

Glad you figured it out

nicklandgrebe avatar Jul 12 '18 12:07 nicklandgrebe