Rails 4 Devise/Omniauth Email exists in database error

不羁岁月 提交于 2019-12-04 17:08:13

I think that's because default Devise installation creates unique key on email coulmn. In your case it's empty, hence second user doesn't have unique one (because empty string is taken by the first user).

Migration in my case

class AllowNullEmail < ActiveRecord::Migration
  def up
    remove_index :users, :email
    change_column :users, :email, :string, :null => true
  end

  def down
    change_column :users, :email, :string, :null => false
    add_index :users, :email, unique: true
  end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!