Rendering Partials as Objects with Parameters?

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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

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 [email protected] 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

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 [email protected] 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.