I have having a problem saving the sign up form using Devise. I am using rails 3.1.1, ruby 1.9.2 and devise 1.4.8. Also, I am using mongoid 2.3.2.
user.rb
class User
include Mongoid::Document
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
#fields in addition to Devise fields.
field :name
field :display_name
index :display_name, :unique=>true
field :gender
field :website
field :about
#referenced documents
has_many :accomplishments
has_many :projects
has_many :ranks
#self reference for followers and followees
references_and_referenced_in_many :followees, :class_name=>"User", :inverse_of=>:followers
references_and_referenced_in_many :followers, :class_name=>"User", :inverse_of=>:followees
#validations
validates_uniqueness_of :display_name, :message=>"Display name already exists.", :allow_nil=>true
validates_presence_of :name, :message=>" is required"
attr_accessible :email, :password, :password_confirmation, :name
end
And my signup form is pretty straight forward as well.
/views/devise/registrations/new.html.erd
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p>
<%= f.label :email %>
<div class="input">
<%= f.email_field :email %>
</div>
</p>
<p>
<%= f.label :password %>
<div class="input">
<%= f.password_field :password %>
</div>
</p>
<p>
<%= f.label :confirmation %>
<div class="input">
<%= f.password_field :password_confirmation %>
</div>
</p>
<p>
<%= f.label :name %>
<div class="input">
<%= f.text_field :name %>
</div>
</p>
<br/>
<p><%= f.submit "Sign up", :class => "btn primary" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
My problem is that when I submit, I get no errors and the flash tells me I successfully signed up. But when you take a look in the users collection in mongo, no documents exist. I have tried making my users model pretty bare bones and modified the sign up page accordingly and still end up with the same result. I am running out of ideas on what to look for to determine why the record is not saving. Any thoughts on what could be going wrong?
Also if more details are needed or a better explanation of the problem, I am more than happy to dive further. Hitting a brick wall on what to check next to resolve the problem.
Found the problem. Apparently some documents within my users collection were conflicting with the validation of the email address I was trying to submit. The document within the collection was manually entered, but did not contain the same email address that I was trying to sign a new user up for. I suppose letting devise handle all user creation would be a good rule of thumb to keep this error from happening in the future.
EDIT
Seems to be if any document exists, wether create by devise or manually, registration seems to fail.
EDIT AGAIN
The problem is that indexes were set in previous development that were not matched with what was declared in the model. Since mongoid does not retract previous declarations, the index still existed and threw an exception within mongo. Why this did not throw an exception in app is beyond me. Had to use db.system.profile.find() to watch the log.