Forum: Ruby on Rails Passing an array of hash to a render partial gives nil

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Carl H. (Guest)
on 2007-06-06 20:03
(Received via mailing list)
It looks like there is a problem passing an array of hash to a partial
render via a collection.

I am trying to do the following:

<%= render :partial => "listshop", :collection => @pca %>

and @pca has the following:

@pca =
@pca << Hash["test" => "1"]
@pca << Hash["test" => "2"]

and in _listshop.erb, I have the following:
<%= listshop["test"] %>

I get an "You have a nil object when you didn't expect it!" error. If
I pass a value  instead of a hash it works fine and if I manually
iterate through the array it works fine as well.

Anybody knows why? Am I doing something wrong?

Carl H. (Guest)
on 2007-06-11 15:30
(Received via mailing list)
My bad,

<%= listshop["test"] %>  should be <%= test %>
This topic is locked and can not be replied to.