apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

error when gmap is in "if" block #122

Closed mogadget closed 12 years ago

mogadget commented 12 years ago

Hi, I wanted to control the map zoom so if search return just 1 enable auto_adjust the set the zoom to 12, it used to work before but when I moved to rails 3.1 im getting this strange error.

undefined method `>' for {[false, false, false, false]=>1}:ActiveSupport::OrderedHash

I put the gmap in my app helper i called it show_map

def show_map(hits, markers)
    if hits > 1 then
        gmaps(:markers => {:data => markers},:map_options => {:container_id => "front-container",:id => "map", :zoom=> 0})
    else
       gmaps(:markers => {"data" => markers},:map_options => {:container_id => "front-container",:id => "map", :auto_adjust => true,:auto_zoom => false, :zoom => 12})
   end  
end

in my view (haml)

=show_map(@thehits.size, @gmark)

Have you seen this before or maybe im missed anything?

mogadget commented 12 years ago

my bad.. i should have used length instead of size because it;s a hash.

=show_map(@thehits.length, @gmark)