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

undefined method `authenticate_user!' when User class nested in module #1234

Closed
WojciechKo opened this issue Nov 1, 2018 · 3 comments
Closed

Comments

@WojciechKo
Copy link

Hey!
I've seen a few of the issues that describes following error and gives us a way to deal with it when mount_devise_token_auth_for is nested inside of namespace in Rails routing. #182

*** NoMethodError Exception: undefined method `authenticate_user!' for"

I found out that when you nest your model inside of a module, the helper-methods names changes as well.

module Models
  class User < ApplicationRecord
    include DeviseTokenAuth::Concerns::User
  end
end
Rails.application.routes.draw do
  mount_devise_token_auth_for 'Models::User', at: 'auth'
end
class ApplicationController < ActionController::API
  include DeviseTokenAuth::Concerns::SetUserByToken
  before_action :authenticate_models_user!
end

Do you have any proposition how to get authenticate_user in given example without method aliasing?

@MaicolBen
Copy link
Collaborator

@WojciechKo and how can we find the class? User itself doesn't exist in your codebase, and I don't think method aliasing for this case is bad. Sorry about that!

@WojciechKo
Copy link
Author

Probably we can't. Was hoping for some kind of configuration option or something.
Anyway, thanks for clarification and for this awesome gem!

@MaicolBen
Copy link
Collaborator

Yeah sorry, we have tons of configurations and we cannot contemplate each case (that's the problem with engines).

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

No branches or pull requests

2 participants