-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
I have a m which uses 2d index. When saving lat/lng, document is not created so I needed to convert it to float using to_f. For example
location = Array.new if !params[:lat].blank? location << params[:lat].to_f end if !params[:lng].blank? location << params[:lng].to_f end item = Item.new({ location: location }).save
The model looks something like:
class Item include Mongoid::Document include Mongoid::Timestamps field :location, :type => Array index({ location: "2d" }) end
Problem now is data stored is rounded instead of storing the actual value that I am passing since I am using float and It concerns me that some precision on lat/lng might be lost.
Is there a way to force Mongoid/Rails to use double type as mongodb supports double data type.
Thanks