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?
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.
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?