On Feb 5, 11:19 am, Craig White <craigwh...@azapple.com> wrote:
> YM4R_GM plugin...
>
> This controller code works but clearly has limitations...
>
>    map_1 = GMarker.new([...@salons[0].lat, @salons[0].lng])
>   �...@map.overlay_init(map_1)
>
> but I really need this in a loop...
>
>     for salon in @salons do
>       map_id += 1
>       map_id_ = "map_id_" + map_id.to_s
>       map_id = Gmarker.new([salon.lat, salon.lng])
>       @map.overlay_init(map_id)
>     end
>
> But inside the loop, I get the following error that I can't seem to
> figure out a way to prevent...
>
> NameError (uninitialized constant SalonsController::Gmarker):
>
> How to use the Gmarker method inside a loop?
>
> Craig
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.

Ruby is case-sensitive. And that loop is rather sketchy... what you're
doing can just be replaced with something like

@salons.each {|salon| @map.overlay_init GMarker.new([salon.lat,
salon.lng])}

If you end up actually needing the array indices, each_with_index will
do nicely.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to