Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with controller scopes including underscores #49

Open
le-martre opened this issue Jul 11, 2018 · 1 comment
Open

Problem with controller scopes including underscores #49

le-martre opened this issue Jul 11, 2018 · 1 comment

Comments

@le-martre
Copy link

le-martre commented Jul 11, 2018

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 le-martre changed the title Caprese is looking for a record inside the scope of my Controller Problem with controller scopes including underscores Jul 11, 2018
@nicklandgrebe
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants