# Rendering Partials as Objects with Parameters?

**URL:** <https://www.ruby-forum.com/t/rendering-partials-as-objects-with-parameters/180869>\
**Category:** Rails\
**Created:** [December 30, 2009, 11:27pm UTC](https://www.ruby-forum.com/t/rendering-partials-as-objects-with-parameters/180869 "2009-12-30T23:27:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeonS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c77e96/32.png) [@LeonS](https://www.ruby-forum.com/u/LeonS)\
**Post date:** [December 30, 2009, 11:27pm UTC](https://www.ruby-forum.com/t/rendering-partials-as-objects-with-parameters/180869/1 "2009-12-30T23:27:39Z")

</div>

Hi,

i try to understand the rendering of partials as objects.  
So, lets imagine i’ve got Threads with posts , and i will just render  
the posts of one thread.  
The code to render all posts will seems to be something like that:  
\<%= render :partial =\> @posts %\>

But how can i just render the posts of one thread, so i will set a  
parameter with the thread\_id  
or something like that. Can i do this with a ;local ? Where can i  
acces the parameter i use to render partial objects?

thanks

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![LeonS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c77e96/32.png) [@LeonS](https://www.ruby-forum.com/u/LeonS)\
**Post date:** [December 30, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/rendering-partials-as-objects-with-parameters/180869/2 "2009-12-30T23:41:44Z")

</div>

Try this:  
render :partial =\> ‘post’, :collection = @posts  
or  
@posts.each do |post|  
render :partial =\> ‘post’, :object =\> post  
end  
Which seems to be slightly faster if less elegant.

On Dec 30, 5:26 pm, LeonS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> or something like that. Can i do this with a ;local ? Where can i  
> acces the parameter i use to render partial objects?
> 
> thanks

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![LeonS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c77e96/32.png) [@LeonS](https://www.ruby-forum.com/u/LeonS)\
**Post date:** [December 31, 2009, 12:24am UTC](https://www.ruby-forum.com/t/rendering-partials-as-objects-with-parameters/180869/3 "2009-12-31T00:24:30Z")

</div>

So, i have to fill an collection of objects (posts) in the Controller  
and then  
i can generate the partial output with the collection of objects.  
Does there isn’t another way , where i don’t have to do that in the  
action controller,  
e.g. to call the the resource from the template?

thanks

On 30 Dez., 23:40, David [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > parameter with the thread\_id  
> > or something like that. Can i do this with a ;local ? Where can i  
> > acces the parameter i use to render partial objects?
> 
> > thanks

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
