Search code examples
ruby-on-railsviewpartialgmaps4rails

Gmaps4rails - Generic info window in model, but overwritten in controller


I have a model called store which have defined this:

def gmaps4rails_infowindow
 html_window = ''
 html_window = "<b>#{self.location_name}"
end

I want this window for all the maps that I render except for one that I want to create a infowindow from a template.

I have this code in my controller:

@list_of_stores = Store.all.to_gmaps4rails do |store,marker|
 marker.infowindow render_to_string(:partial => 'store_window', :locals => {:store => store}
end

I am able to render the window with the partial if I get rid of the gmaps4rails_infowindow in the model. Otherwise, the content of the windows is always the one that is set in the model.

How can I overwrite that? I want to have that method in the model, but in some cases I want to avoid using it, and just use what I have in a partial.


Solution

  • Now available in v1.5.1, enjoy!