Hi,
This should work.
<% for thread in @threads %>
<%= render :partial => ''threadtop'', :locals=>
{:thread => thread } %>
<% for reply in @replies %>
<%= render :partial => "reply", :locals=> {:reply=>
reply } %>
<% end %>
<% end %>
-Eric
ericgoodwin.com
Eleo wrote:> This only works when the partial name matches the object name; if I
> change "threadtop" to "thread" then it works fine. Is
this normal? I
> get the following error otherwise:
>
> "undefined local variable or method `thread''"
>
> index.rhtml
> ---
> <% for @thread in @threads %>
> <%= render :partial => ''threadtop'', :object =>
@thread %>
> <% for @reply in @replies %>
> <%= render :partial => "reply", :object => @reply
%>
> <% end %>
> <% end %>
>
>
> _threadtop.rhtml:
> ---
> <div class="threadtop">
> <% if thread.image_name != "" %>
> <% end %>
>
> <p>
> <span class="subject"><%= thread.subject
%></span>
> <span class="name"><%= thread.name %></span>
> <span class="date"><%=
thread.date.strftime("%m/%d/%Y %H:%M")
> %></span>
> <span class="num">No. <%= thread.num
%></span>
> <span class="reply">
> [<%= link_to "Reply", :controller =>
["imageboard", params[:board]],
> :action => ["reply"], :id => thread.num %>]
> </span>
> </p>
>
> <% if thread.comment != "" %>
> <blockquote><%= thread.comment %></blockquote>
> <% end %>
> </div>
>
>