0

I'm trying to build a new Rails app with MongoDB using Mongoid as the ORM. The authentication is handled by the sorcery gem.

I'm getting the following error in my Users#new view.

undefined method 'password_confirmation' for #<User:0x007feff2a23890>

My model looks like this.

class User                                                                                                                                                              
 include Mongoid::Document                                                                                                                                             
 authenticates_with_sorcery!                                                                                                                                           

 attr_accessible :username, :email, :password, :password_confirmation                                                                                                  

 field :username                                                                                                                                                       
 field :email                                                                                                                                                          
 field :password                                                                                                                                                       
end

I get this error if I don't have a field definition in the model for each field. The password_confirmation field is a virtual field, so it shouldn't have a field definition anyway. How do I use dynamic and virtual fields in Mongoid (which are set to true in the config) with form helpers?

1 Answer 1

2

Simply add:

attr_accessor :password_confirmation
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.