You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
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
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.
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 :
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]
andunnamespace(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!
The text was updated successfully, but these errors were encountered: