Getting Error from Devise "User Does Not Respond to 'Devise' Method" When Running "Rails Generate Devise:Install"

getting error from devise User does not respond to 'devise' method when running rails generate devise:install

It sounds like you already have the devise method being called in your User model. Perhaps you already ran rails g devise User ?

Comment that out, and comment out the devise_for :users line in your routes file, if that is in there.

User does not respond to 'devise' method

check this question

getting error from devise "User does not respond to 'devise' method" when running "rails generate devise:install"

1st answer will probably solve your problem.

I ran rails generate devise MODEL before rails generate devise:install

You can undo generation commands with rails destroy ..., so in your case it would be:

$ rails destroy devise MODEL

If that doesn't work for whatever reason, you can just delete the model and migration - they're only files.

Installing Devise: `PG::UndefinedTable: ERROR: relation users does not exist`

Did you have a User model before? It seems that devise thought that too and it's trying to add its columns to a non-existent User model.

This is what I would do...

  1. Run rails db:drop
  2. Delete db/schema.rb file.
  3. Delete db/migrate/20190915133638_add_devise_to_users.rb
  4. Run rails generate devise:install again
  5. Run rails db:migrate

EDIT

If the previous steps didn't work then try to create a users table before devise's migration.

For this follow these steps:

  1. rails g model User
  2. Change the name of the migration file so it will be executed right before the AddDeviseToUsers migration.
  3. Run rails db:migrate


Related Topics



Leave a reply



Submit