Using Rails form helpers with Mongoid

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                                                                                                                                             

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

 field :username                                                                                                                                                       
 field :email                                                                                                                                                          
 field :password                                                                                                                                                       

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?


Simply add:

attr_accessor :password_confirmation

Need Your Help

How to override the Exception Class and not to display the Fatal error

php class api exception error-handling

I am trying to write a class that communicate with an API. I would like to override the standard Exception class in PHP to return the message, error code that I want.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.