-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Hi,
I am using mongoid 4.0.0.alpha2 (commit `e7aef3bc79`)
I have a model with a column with the type Integer.
class FeedProduct include Mongoid::Document field :e, as: :ean, type: Integer end
When I set the attribute with a String that has a dot, Mongoid sets it to 0, which at least to me is unexpected behaviour.:
>> FeedProduct.new(ean: "713132333822.") => #<FeedProduct _id: fff7cce20000eff7d3ccbbf8, e(ean): 0>
If the string has just numbers it works correctly.
This solves the problem:
def ean=(new_ean) write_attribute(:ean, new_ean.try(:to_i)) end
Is this a known issue? expected behaviour?