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

devise_token_auth 1.1.0 installation fails with "undefined method 'devise' for User" #1276

Open
drj17 opened this issue Mar 31, 2019 · 7 comments

Comments

@drj17
Copy link

@drj17 drj17 commented Mar 31, 2019

When posting issues, please include the following information to speed up the troubleshooting process:

  • Version: 1.1.0
  • Rails Version: 5.2.3
  • Rails Stacktrace:
rake aborted!
NoMethodError: undefined method `devise' for User (call 'User.connection' to establish a connection):Class
/app/models/user.rb:8:in `include'
/app/models/user.rb:8:in `<class:User>'
/app/models/user.rb:3:in `<main>'
/config/routes.rb:2:in `block in <main>'
/config/routes.rb:1:in `<main>'
/config/environment.rb:5:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)

Given the current installation settings in the documentation, installation fails in a brand new rails project.

@drj17 drj17 changed the title devise_token_auth 1.1.0 is unusable, fails with "undefined method 'devise' for User" devise_token_auth 1.1.0 installation fails with "undefined method 'devise' for User" Mar 31, 2019
@vinhkq

This comment has been minimized.

Copy link

@vinhkq vinhkq commented Apr 2, 2019

@drj17
You can add extend Devise::Models in User.rb Model.
It fixed for me.

@dks17

This comment has been minimized.

Copy link
Contributor

@dks17 dks17 commented Apr 6, 2019

This is Devise issue, but not the gem. And this is a Stack Overflow question.

ActiveRecord ORM was hard coded inside of the gem before. Now you must follow by Devise configuration.

  # ==> ORM configuration
  # Load and configure the ORM. Supports :active_record (default) and
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
  # available as additional gems.
  require 'devise/orm/<%= options[:orm] %>'

Check also the gem doc.

@jeffjiang0613

This comment has been minimized.

Copy link

@jeffjiang0613 jeffjiang0613 commented Apr 14, 2019

I have met with the same issue in version 1.1.0, when I change the devise_token_auth to previous version 1.0.0, it works.

@drj17

This comment has been minimized.

Copy link
Author

@drj17 drj17 commented Apr 14, 2019

I would argue this is not a devise issue because you cannot install this gem with the readme as is. Perhaps someone would like to make that pull request? I could do it one I get access to a computer

@reneclavijo

This comment has been minimized.

Copy link

@reneclavijo reneclavijo commented Apr 17, 2019

I had the same issue, and just with 1.0.0 version works fine. If I use extend Devise::Models in User.rb raise an error with /auth/sign_in (creating sessions)

@CDimonaco

This comment has been minimized.

Copy link

@CDimonaco CDimonaco commented May 21, 2019

The update to the latest version should be documented in a better way, the way to go is create an initializer for devise and load active record, like @drj17 said, the changelog of this gem does not mention the upgrade step, and does not mention the new devise dependency.

I think we should definitely put something in the installation documentation, or at least an 'upgrade' section in the gem docs.

mc-chinju added a commit to mc-chinju/qiita_clone that referenced this issue Jun 14, 2019
aaaaninja added a commit to aaaaninja/happy_trigger that referenced this issue Aug 15, 2019
lynndylanhurley/devise_token_auth#1276

こんなバグが現在ある, ので提示されていた解決法をやった.

現在のroute
```
                   Prefix Verb   URI Pattern                                                                              Controller#Action
         new_user_session GET    /auth/sign_in(.:format)                                                                  devise_token_auth/sessions#new
             user_session POST   /auth/sign_in(.:format)                                                                  devise_token_auth/sessions#create
     destroy_user_session DELETE /auth/sign_out(.:format)                                                                 devise_token_auth/sessions#destroy
        new_user_password GET    /auth/password/new(.:format)                                                             devise_token_auth/passwords#new
       edit_user_password GET    /auth/password/edit(.:format)                                                            devise_token_auth/passwords#edit
            user_password PATCH  /auth/password(.:format)                                                                 devise_token_auth/passwords#update
                          PUT    /auth/password(.:format)                                                                 devise_token_auth/passwords#update
                          POST   /auth/password(.:format)                                                                 devise_token_auth/passwords#create
 cancel_user_registration GET    /auth/cancel(.:format)                                                                   devise_token_auth/registrations#cancel
    new_user_registration GET    /auth/sign_up(.:format)                                                                  devise_token_auth/registrations#new
   edit_user_registration GET    /auth/edit(.:format)                                                                     devise_token_auth/registrations#edit
        user_registration PATCH  /auth(.:format)                                                                          devise_token_auth/registrations#update
                          PUT    /auth(.:format)                                                                          devise_token_auth/registrations#update
                          DELETE /auth(.:format)                                                                          devise_token_auth/registrations#destroy
                          POST   /auth(.:format)                                                                          devise_token_auth/registrations#create
      auth_validate_token GET    /auth/validate_token(.:format)                                                           devise_token_auth/token_validations#validate_token
             api_v1_posts GET    /api/v1/posts(.:format)                                                                  api/v1/posts#index
                          POST   /api/v1/posts(.:format)                                                                  api/v1/posts#create
              api_v1_post GET    /api/v1/posts/:id(.:format)                                                              api/v1/posts#show
                          PATCH  /api/v1/posts/:id(.:format)                                                              api/v1/posts#update
                          PUT    /api/v1/posts/:id(.:format)                                                              api/v1/posts#update
                          DELETE /api/v1/posts/:id(.:format)                                                              api/v1/posts#destroy
       rails_service_blob GET    /rails/active_storage/blobs/:signed_id/*filename(.:format)                               active_storage/blobs#show
rails_blob_representation GET    /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
       rails_disk_service GET    /rails/active_storage/disk/:encoded_key/*filename(.:format)                              active_storage/disk#show
update_rails_disk_service PUT    /rails/active_storage/disk/:encoded_token(.:format)                                      active_storage/disk#update
     rails_direct_uploads POST   /rails/active_storage/direct_uploads(.:format)                                           active_storage/direct_uploads#create
```
@dkniffin

This comment has been minimized.

Copy link
Contributor

@dkniffin dkniffin commented Oct 18, 2019

Any progress on this? I'm running into the same issue. @Tiltorito I see you opened a PR but the tests were failing. To me it looks like the reason was an intermittent issue with Travis. You could try restarting the build and that might fix it, but I could be way off base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.