# Cannot get partial with collections to work

**URL:** <https://www.ruby-forum.com/t/cannot-get-partial-with-collections-to-work/186747>\
**Category:** Rails\
**Created:** [February 25, 2008, 6:47pm UTC](https://www.ruby-forum.com/t/cannot-get-partial-with-collections-to-work/186747 "2008-02-25T18:47:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 25, 2008, 6:47pm UTC](https://www.ruby-forum.com/t/cannot-get-partial-with-collections-to-work/186747/1 "2008-02-25T18:47:33Z")

</div>

Hi everyone-

Just learning Rails, and I’m wondering if someone can help me out. I  
have a story controller:

class StoriesController \< ApplicationController

def index  
@stories = Story.find(:all)  
end

end

and an index file to render the index action:

\<%= @stories.size %\> stories so far. # THIS WORKS, I SEE THAT I  
HAVE 2 STORIES

# Stories

\<% render :partial =\> 'story', :collection =\> @stories %\>

and a partial, \_story.html.erb:

- \<%= story.headline %\>

no matter what I try, I do not see the partial render. If do see that  
the variable is good, because I see the number “2” (I have 2 stories  
in the dummy database). Also, If I put static html in the partial,  
still, it doesn’t render. However, if I put some bogus embedded ruby  
in the partial, it causes an error, so I know it’s reading the  
partial.

Any suggestions?

Thanks,  
Dino

---

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 25, 2008, 6:56pm UTC](https://www.ruby-forum.com/t/cannot-get-partial-with-collections-to-work/186747/2 "2008-02-25T18:56:38Z")

</div>

\<% render :partial =\> ‘story’, :collection =\> @stories %\>  
should be  
\<%= render :partial =\> ‘story’, :collection =\> @stories %\>

---

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 25, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/cannot-get-partial-with-collections-to-work/186747/3 "2008-02-25T18:58:07Z")

</div>

On 25 Feb 2008, at 17:46, dino d. wrote:

> \<% render :partial =\> ‘story’, :collection =\> @stories %\>

> no matter what I try, I do not see the partial render. If do see that  
> the variable is good, because I see the number “2” (I have 2 stories  
> in the dummy database). Also, If I put static html in the partial,  
> still, it doesn’t render. However, if I put some bogus embedded ruby  
> in the partial, it causes an error, so I know it’s reading the  
> partial.

You need \<%= render :partial … not \<% render :partial  
In general things that are blatantly just going to produce a chunk of  
html go in \<%= blocks

Fred

---

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [February 25, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/cannot-get-partial-with-collections-to-work/186747/4 "2008-02-25T19:01:04Z")

</div>

thanks for the fast reply, i knew i was having some newbie problem!

dino

On Feb 25, 12:56 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
