-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I haven't had the time to check if this is particular to being embedded. I'm using ruby 2.0.0-p0 and mongoid 3.1.3, I previously had mongoid 3.0.19 which also displayed unintended behavior.
The relevant part of my model is:
class Foo include Mongoid::Document field :lorem, type: Date embedded_in :bar end class Bar include Mongoid::Document include Mongoid::Timestamps belongs_to :user embeds_many :foo accepts_nested_attribuets_for :foo validates_presence_of :user end
The problem I have is when updating attributes on a controller on rails:
@bar = current_user.bar # given that params[:bar] contains a Foo with and invalid :lorem, such as "2013-04-00" # when it's valid it works ok, but when not, this very next line will cause an exception if @bar.update_attributes(params[:bar]) # ... else # ... end
On mongoid 3.0.19 that exception is ArgumentError: argument out of range.
On mongoid 3.1.3 that exception is
Unable to find source-code formatter for language: nomethoderror. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
undefined method `__bson_dump__'
.
I've looked up for the latter and found out that mongoid won't work properly if bson_ext is loaded, however there are no bson gems whatsoever on my Gemfile.lock, thus it's probably not the case.