Forum: Ruby on Rails render partial, object.property missing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
matthew collins (Guest)
on 2006-02-05 17:29
(Received via mailing list)
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:

<tr>
    <td><%= post.title%>
            <br />
    <%= post.body%>
<br />

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
Wilson B. (Guest)
on 2006-02-05 18:08
(Received via mailing list)
On 2/5/06, matthew collins <removed_email_address@domain.invalid> 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. :)
matthew collins (Guest)
on 2006-02-05 18:14
(Received via mailing list)
not to burn bandwidth with a simple 'thanks'; but, wow --- that's
simple.

thanks!
This topic is locked and can not be replied to.