Of course, read the doc here.
Here is the example provided when you work in your controller:
@json = User.all.to_gmaps4rails do |user, marker|
marker.infowindow render_to_string(:partial => "/users/my_template", :locals => { :object => user})
marker.picture({
:picture => "http://www.blankdots.com/img/github-32x32.png",
:width => 32,
:height => 32
})
marker.title "i'm the title"
marker.sidebar "i'm the sidebar"
marker.json({ :id => user.id, :foo => "bar" })
end
I tend to put infowindow code in partials since its cleaner, but you're not compelled to use this abstraction.
I assume you use version < 2.x otherwise, the relevant doc is here and the method has changed.