Note that there are some explanatory texts on larger screens.

plurals
  1. POFactory Girl, Mongoid, and Embedded Documents
    text
    copied!<p>I am setting up my first app with Mongoid and Devise. I am trying to Factory a user in my test with this factory:</p> <pre><code>Factory.define(:user) do |f| f.email "bob1234@example.com" f.password "testing" f.password_confirmation "testing" end </code></pre> <p>When I try and factory this I get this error:</p> <pre><code>NoMethodError: undefined method `add_on_blank' for []:Array from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/criteria.rb:213:in `send' from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/criteria.rb:213:in `method_missing' from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/relations/embedded/many.rb:373:in `send' from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/relations/embedded/many.rb:373:in `method_missing' from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/named_scope.rb:121:in `with_scope' from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/relations/embedded/many.rb:372:in `send' from /Library/Ruby/Gems/1.8/gems/mongoid-2.0.1/lib/mongoid/relations/embedded/many.rb:372:in `method_missing' </code></pre> <p>My models look like:</p> <p>User:</p> <pre><code>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 attr_accessible :email, :password, :password_confirmation, :remember_me embeds_many :errors end </code></pre> <p>Error:</p> <pre><code>class Error include Mongoid::Document field :klass, :type =&gt; String embedded_in :user end </code></pre> <p>How should a user model be created without creating any embedded documents at the same time?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload