views:

42

answers:

1

I'm using the partial "infowindow" (app/view/tech/_infowindow.html.erb) to populate a google map marker using:

new_marker = GMarker.new([t.lat, t.lng], :icon => icon, :title => t.summary, :info_window => (render_to_string :partial => "infowindow", :object => t))

but i'm getting a very odd error. When I simply put:

<%= debug(infowindow) %>

I get the full output of the hash. But when I try to reference any of the individual attributes like:

<%= infowindow.summary %>

I get thrown an undefined method `summary' for nil:NilClass even though the attribute shows up in the debug output for the entire hash. Why can I only access the entire hash and not its individual attributes in the partial?

EDIT: The top part of the returned hash:

!ruby/object:Ticket 
attributes: 

The model being used is a Ticket object if that helps.

+2  A: 

What you are trying to do is call the method summary on the infowindow hash which does not exist in the Hash Class and hence the error. To access individual hash elements try this

<%= infowindow["summary"] %>
Anand
It *could* be available as a method too if the plugin writer was smart.
Ryan Bigg
I'm still getting an error that now it's a nil object... The variable being passed is a Ticket object with, for example, a summary column. If the infowindow is the local variable for the Ticket object, why can't I just do infowindow.summary in the same model.attribute syntax used elsewhere?
Kevin