Question: How can I achieve the model design below using ActiveAdmin and Devise 2?
I have set up active_admin successfully with an existing User
model for bootstrapping it.
I assumed this model design means ("Have adminusers manage users").
Here is my current model set up:
irb(main):003:0> User.column_names
=> ["id", "created_at", "updated_at", "avatar", "name"]
irb(main):004:0> AdminUser.column_names
=> ["id", "email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "created_at", "updated_at"]
Now I would like to add some authenticaton for my User model. However I am unable to migrate the results of rails generate devise User
without this conflict:
== AddDeviseToUsers: migrating ===============================================
-- change_table(:users)
-> 0.7201s
-- add_index(:users, :email, {:unique=>true})
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: could not create unique index "index_users_on_email"
DETAIL: Key (email)=() is duplicated.
: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
Tasks: TOP => db:migrate
Now I do not have an email
attribute in my current User model, but AdminUser does. So when Devise tries to create the email attribute in User
I suspect this is why I get this error. But why? They are in different models?
Any help e.g. experiences, posts or tutorials would be appreciated (as well as an answer)
NOTE I have tried the solution found on the Devise wiki and here, with no success on migration.