# Passing an array of hash to a render partial gives nil

**URL:** <https://www.ruby-forum.com/t/passing-an-array-of-hash-to-a-render-partial-gives-nil/106129>\
**Category:** Rails\
**Created:** [June 6, 2007, 6:03pm UTC](https://www.ruby-forum.com/t/passing-an-array-of-hash-to-a-render-partial-gives-nil/106129 "2007-06-06T18:03:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9f8e36/32.png) [@hamrin](https://www.ruby-forum.com/u/hamrin)\
**Post date:** [June 6, 2007, 6:03pm UTC](https://www.ruby-forum.com/t/passing-an-array-of-hash-to-a-render-partial-gives-nil/106129/1 "2007-06-06T18:03:58Z")

</div>

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 = Array.new  
@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

---

<div class="post-metadata">

**Author:** ![hamrin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9f8e36/32.png) [@hamrin](https://www.ruby-forum.com/u/hamrin)\
**Post date:** [June 11, 2007, 1:30pm UTC](https://www.ruby-forum.com/t/passing-an-array-of-hash-to-a-render-partial-gives-nil/106129/2 "2007-06-11T13:30:45Z")

</div>

My bad,

\<%= listshop[“test”] %\> should be \<%= test %\>
