Here's what I did successfully to install Devise:
bundle install
rails generate devise:install
rake db:migrate
(successfully) just to be safeNow when I try to do rails generate devise User
I get the following error:
== 20190915133638 AddDeviseToUsers: migrating =================================
-- change_table(:users)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "users" does not exist
: ALTER TABLE "users" ADD "email" character varying DEFAULT '' NOT NULL
I tried this adding a few custom fields to the devise migration, but then again with the autogenerated migration and got the same result either way.
Can anyone see how I'm getting this error? I've tried rake db:reset db:create db:migrate
but to no avail.
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...
rails db:drop
db/schema.rb
file.db/migrate/20190915133638_add_devise_to_users.rb
rails generate devise:install
againrails 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:
rails g model User
AddDeviseToUsers
migration.rails db:migrate