Hi, I''m working on a rails/google maps app, where makers on the map show ''places''. I would like to be able to put a link into each marker''s infowindow that will take the user to the ''show'' action for that place (ie. /places/[place_id]), and am looking for ways to output the appropriate url so it can be incorporated into my /public/javascripts/ map.js file. I''m using json to output the latititude, longitude, name etc of each place to the map...is there a way to extend this to urls? Any help would be much appreciated, thanks in advance! -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
FYI: Rails 3beta4, Ruby 1.8.7 and using jQuery with my map. On Jul 2, 5:07 pm, Tig <sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m working on a rails/google maps app, where makers on the map show > ''places''. I would like to be able to put a link into each marker''s > infowindow that will take the user to the ''show'' action for that place > (ie. /places/[place_id]), and am looking for ways to output the > appropriate url so it can be incorporated into my /public/javascripts/ > map.js file. I''m using json to output the latititude, longitude, name > etc of each place to the map...is there a way to extend this to urls? > > Any help would be much appreciated, thanks in advance!-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tig wrote:> Hi, > > I''m working on a rails/google maps app, where makers on the map show > ''places''. I would like to be able to put a link into each marker''s > infowindow that will take the user to the ''show'' action for that place > (ie. /places/[place_id]), and am looking for ways to output the > appropriate url so it can be incorporated into my /public/javascripts/ > map.js file. I''m using json to output the latititude, longitude, name > etc of each place to the map...is there a way to extend this to urls?Of course! URLs are just strings. Stick ''em in the JSON packet with everything else.> > Any help would be much appreciated, thanks in advance!-- Posted via http://www.ruby-forum.com/. -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Awesome, I hoped it would be that easy! Thanks for your help On Jul 2, 10:54 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Tig wrote: > > Hi, > > > I''m working on a rails/google maps app, where makers on the map show > > ''places''. I would like to be able to put a link into each marker''s > > infowindow that will take the user to the ''show'' action for that place > > (ie. /places/[place_id]), and am looking for ways to output the > > appropriate url so it can be incorporated into my /public/javascripts/ > > map.js file. I''m using json to output the latititude, longitude, name > > etc of each place to the map...is there a way to extend this to urls? > > Of course! URLs are just strings. Stick ''em in the JSON packet with > everything else. > > > > > Any help would be much appreciated, thanks in advance! > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi, I''m struggling a bit to get an appropriate url to save - I''ve added a ''link'' column to my ''places'' table, and am populating the hidden form field automatically using @place.link = places_path(@place.id) in the ''new'' action of the places controller. This seems to output just / places however - am I going about this the wrong way? I''m also struggling to incorporate the /places link I''ve exported to JSON into my javascript code...thanks for your help! On Jul 5, 2:41 pm, Tig <sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Awesome, I hoped it would be that easy! Thanks for your help > > On Jul 2, 10:54 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > >Tigwrote: > > > Hi, > > > > I''m working on a rails/google maps app, where makers on the map show > > > ''places''. I would like to be able to put a link into each marker''s > > > infowindow that will take the user to the ''show'' action for that place > > > (ie. /places/[place_id]), and am looking for ways to output the > > > appropriate url so it can be incorporated into my /public/javascripts/ > > > map.js file. I''m using json to output the latititude, longitude, name > > > etc of each place to the map...is there a way to extend this to urls? > > > Of course! URLs are just strings. Stick ''em in the JSON packet with > > everything else. > > > > Any help would be much appreciated, thanks in advance! > > > -- > > Posted viahttp://www.ruby-forum.com/.-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve found a solution - instead of adding a ''link'' column to my ''places'' table, I can just use the place id value to create a link in my js file: <a href=''/places/"+place.id+"''>Show more!</a>" Hope that sounds okay, it seems to work fine! On Jul 7, 5:27 pm, Tig <sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m struggling a bit to get an appropriate url to save - I''ve added a > ''link'' column to my ''places'' table, and am populating the hidden form > field automatically using @place.link = places_path(@place.id) in the > ''new'' action of the places controller. This seems to output just / > places however - am I going about this the wrong way? I''m also > struggling to incorporate the /places link I''ve exported to JSON into > my javascript code...thanks for your help! > > On Jul 5, 2:41 pm,Tig<sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Awesome, I hoped it would be that easy! Thanks for your help > > > On Jul 2, 10:54 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > >Tigwrote: > > > > Hi, > > > > > I''m working on a rails/google maps app, where makers on the map show > > > > ''places''. I would like to be able to put a link into each marker''s > > > > infowindow that will take the user to the ''show'' action for that place > > > > (ie. /places/[place_id]), and am looking for ways to output the > > > > appropriate url so it can be incorporated into my /public/javascripts/ > > > > map.js file. I''m using json to output the latititude, longitude, name > > > > etc of each place to the map...is there a way to extend this to urls? > > > > Of course! URLs are just strings. Stick ''em in the JSON packet with > > > everything else. > > > > > Any help would be much appreciated, thanks in advance! > > > > -- > > > Posted viahttp://www.ruby-forum.com/.-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
A minor observation: I suppose you are taking care of nil objects here: place.id. Otherwise the link will crash if "place" object is nil. I would propose doing something like: place_id = place.id rescue "" # or you put your rescue sub-link here "<a href=''/places/"+place_id+"''>Show more!</a>" Regards, Ceekays. On Jul 8, 11:02 pm, Tig <sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve found a solution - instead of adding a ''link'' column to my > ''places'' table, I can just use the place id value to create a link in > my js file: > > <a href=''/places/"+place.id+"''>Show more!</a>" > > Hope that sounds okay, it seems to work fine! > > On Jul 7, 5:27 pm, Tig <sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I''m struggling a bit to get an appropriate url to save - I''ve added a > > ''link'' column to my ''places'' table, and am populating the hidden form > > field automatically using @place.link = places_path(@place.id) in the > > ''new'' action of the places controller. This seems to output just / > > places however - am I going about this the wrong way? I''m also > > struggling to incorporate the /places link I''ve exported to JSON into > > my javascript code...thanks for your help! > > > On Jul 5, 2:41 pm,Tig<sonia.bracegir...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Awesome, I hoped it would be that easy! Thanks for your help > > > > On Jul 2, 10:54 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > >Tigwrote: > > > > > Hi, > > > > > > I''m working on a rails/google maps app, where makers on the map show > > > > > ''places''. I would like to be able to put a link into each marker''s > > > > > infowindow that will take the user to the ''show'' action for that place > > > > > (ie. /places/[place_id]), and am looking for ways to output the > > > > > appropriate url so it can be incorporated into my /public/javascripts/ > > > > > map.js file. I''m using json to output the latititude, longitude, name > > > > > etc of each place to the map...is there a way to extend this to urls? > > > > > Of course! URLs are just strings. Stick ''em in the JSON packet with > > > > everything else. > > > > > > Any help would be much appreciated, thanks in advance! > > > > > -- > > > > Posted viahttp://www.ruby-forum.com/.-- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.