Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

Displaying Associated Image with Gmaps4rails


I'm using Gmaps4rails to display a map of properties.

The properties model has an associating photo model. Does anybody know how I could implement an associated photo into an info window. My info window method at the moment is as below.

def gmaps4rails_infowindow
    "<strong> #{self.reference} </strong><br /> #{self.bedrooms} bedroom #{self.p_type}<br /> <a href='http://www.crescentlettings.co.uk/properties/#{id}'>See more details</a> " 
end 

Solution

  • It's pretty straight:

    def gmaps4rails_infowindow
      "<img src='#{self.photo.url}'><strong> #{self.reference} </strong><br /> #{self.bedrooms} bedroom #{self.p_type}<br /> <a href='http://www.crescentlettings.co.uk/properties/#{id}'>See more details</a> " 
    end