Render partial, object.property missing

trying to do my first rails app (surprise, it’s a blog!)

anyhow.

in list.rhtml, i have this:

<% for post in @posts

render(:partial => "post", :object=>post)

end %>

and in _post.rhtml, i have:

<%= post.title%>
<%= post.body%>

problem is, no content shows up – displays a blank page. for the
record, if i put that same partial within the list.rhtml, i get the
content displayed correctly.

thanks in advance for the help

On 2/5/06, matthew collins [email protected] wrote:

problem is, no content shows up – displays a blank page. for the
record, if i put that same partial within the list.rhtml, i get the
content displayed correctly.

Try replacing these three lines:
<% for post in @posts %>
<%= render(:partial => “post”, :object=>post) %>
<% end %>

…with:
<%= render :partial => ‘post’, :collection => @posts %>

The other way would be to do:
<% for post in @posts %>
<%= render :partial => ‘post’, :locals => {:post => post} %>
<% end %>

…but that’s three times as much code. :slight_smile:

not to burn bandwidth with a simple ‘thanks’; but, wow — that’s
simple.

thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs