Optional Email Issues with Mongoid+Devise

36 views
Skip to first unread message

upisdown

unread,
Jan 5, 2013, 7:23:54 PM1/5/13
to plataforma...@googlegroups.com
I'm having a peculiar issue that I can not diagnose. I'm trying to make email field optional, I have read a lot about it and can successfully register one account without an email and login. 

However when I try to register a second account, the application will redirect properly and present the 'successful sign up' flash message but the record does not get persistently saved. I can save multiple users persistently record if I supply a unique email address. It does not throw an error about conflicting email addresses unless I specify the same non-blank/non-nil email address. 

I have tried adding the user through console and I get true on .valid?, .save! and even new_record? after the .save! but the record still does not persist. 

I have tried both with :validatable and defining email_required? as false in my user model and writing custom validations and still receive this issue. I have also tried overriding the registrations controller and adding a bang to the save to see if it would throw erros but I did not get any. 

I have tried this with freshly installed applications and I still receive the same issue. 

Beyond just making this work I would really like to know what is going on here, any help would be appreciated. If there is any other information that I could provide that would be helpful to diagnose the issue please let me know. 

  

upisdown

unread,
Jan 6, 2013, 1:36:40 AM1/6/13
to plataforma...@googlegroups.com
I had to delete the index created for the email column. 

rake db:mongoid:remove_indexes

Then everything worked as expected. Guess it was more of a mongoid issue but maybe the answer will help someone eventually. 

José Valim

unread,
Jan 7, 2013, 7:19:16 AM1/7/13
to plataforma...@googlegroups.com
Thanks for posting the solution back! Glad you solved the issue!
Reply all
Reply to author
Forward
0 new messages