Cannot get mongoid_geo to work

17 views
Skip to first unread message

ronin

unread,
Aug 3, 2011, 7:04:27 AM8/3/11
to mongoid-geo
Hello,

I'm trying out mongoid_geo 0.6.0 but I cannot get it to work.
As I understand there is nothing much to configure except to add
'mongoid_geo' gem to the Gemfile.
I get the following error when I try to assign coordinates:
> place.location = "45.1, -3.4"
> Mongoid::Errors::InvalidType: Field was defined as a(n) Array, but received a String with the value "45.1, -3.4".
I guess this is because mongoid_geo is not configured properly.
How to make sure everything is as it should be?

Thanks!

Leo Qiu

unread,
Aug 3, 2011, 7:14:21 AM8/3/11
to mongo...@googlegroups.com
def loc_str_to_array args
args.kind_of?(String) ? args.split(",").map(&:to_f) : args
end

Cyprian Kowalczyk

unread,
Aug 3, 2011, 7:17:16 AM8/3/11
to mongo...@googlegroups.com
This is the "old" manual way, isn't it?
I would like to use the "new :geo option that can be used with any Array field".

Kristian Mandrup

unread,
Aug 3, 2011, 7:44:01 AM8/3/11
to mongoid-geo
Please use mongoid_spatial by Ryan Ong instead.

I have had no time to finish this gem unfortunately, but he has done a
good job on continuing my efforts in his gem which should be
working ;)

If you wanna help get this gem working as well, look at his code and
patch this gem where necessary. Mostly in geo_context.rb and such.
(run the specs)

Kristian


On Aug 3, 1:17 pm, Cyprian Kowalczyk <cyprian...@gmail.com> wrote:
> This is the "old" manual way, isn't it?
> I would like to use the "new :geo option that can be used with any Array field".
>
> On 3 sie 2011, at 13:14, Leo Qiu wrote:
>
>
>
>
>
>
>
> >     def loc_str_to_array args
> >       args.kind_of?(String) ? args.split(",").map(&:to_f) : args
> >     end
>

Cyprian Kowalczyk

unread,
Aug 3, 2011, 7:54:19 AM8/3/11
to mongo...@googlegroups.com
Thanks for the info Kristian!
Reply all
Reply to author
Forward
0 new messages