Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7545101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:50:31+00:00 2026-05-30T08:50:31+00:00

Question: How can I achieve the model design below using ActiveAdmin and Devise 2?

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:50:32+00:00Added an answer on May 30, 2026 at 8:50 am

    The problem is in the creation of the index. Since you are changing the table, I’m assuming you already have records in it – trying to add an email column and subsequently add a unique index on it will not work because the column won’t have unique values yet. Devise adds an index on the email column because it is the primary login field – if you have a different field for login (say, username), then add the index on that instead. If you are planning to start using email for login, then remove the index for now and add it once you have populated the email column with unique values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model Question which can have several Answer instances, each one with
this question can create a misunderstanding: I know I have to use CSS to
Here is the question: Can TortoiseSvn work on Windows 2008 without turning off User
I have a question about GUI design, specifically with Java Swing and creating clean
I am beginner.Practicing in C# 3.0. The requirement is i have to design model
Say we have two aggregate roots in a domain model: Group and User. Now,
Both OOD (Object-Oriented-Design) and MVC (Model-View-Controller) architectures have become staples of modern software design.
I am developing an application using sharepoint 2010 server side object model. Can anyone
I have a question regarding the best design pattern for code reuse when dealing
I need to know how can I set Hibernate (...) to achieve the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.