Devise Admin Role: PG::Error: ERROR: relation “adm

2019-05-07 03:32发布

问题:

After successfully configuring devise with users I am now trying to add an Admin role in preparation of using rails_admin.

I followed these instructions (https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role) to add the admin role to devise even though the migration generated looked completely different from that in the instructions. I then ran "bundle exec rake db:migrate" only to get the error:

PG::Error: ERROR:  relation "admins" already exists

At this point I had not attempted to install rails_admin because I wanted to get devise working fully first.

Any ideas why I got this error when I did not previously have an admin model?

回答1:

Solution thanks to wildplasser: run db:drop -> db:create -> db:migrate to reset the database!