# Passing variable

**URL:** <https://www.ruby-forum.com/t/passing-variable/144658>\
**Category:** Rails\
**Created:** [July 31, 2008, 9:50pm UTC](https://www.ruby-forum.com/t/passing-variable/144658 "2008-07-31T21:50:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 31, 2008, 9:50pm UTC](https://www.ruby-forum.com/t/passing-variable/144658/1 "2008-07-31T21:50:23Z")

</div>

def view\_history  
@posts = Post.search\_by\_requirement\_id(params[:id], params[:page])  
end

view\_history.html.erb

\<%= render :partial =\> :threads, :collection =\> @posts %\>

The @posts in view\_history doesn’t seem to make it to the  
\_threads.html.erb

Help!!

Thanks! =)

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 31, 2008, 9:58pm UTC](https://www.ruby-forum.com/t/passing-variable/144658/2 "2008-07-31T21:58:27Z")

</div>

I believe there is a naming convention to follow if you’re using  
the :collection option. if your collection is called @posts your  
partial should be called the singular (\_post.html.erb).

Try then

\<%= render :partial =\> :post, :collection =\> @posts %\>

I’m sure there are other (better) ways to do this… I’ve had success  
following this convention tho.

HTH

SH

On Jul 31, 12:50 pm, Justin To [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
