Can't get render... :collection to work?


#1

Hi all -

New to Rails so I’m hoping this is something obvious, but I can’t get it
to work. Here’s my view:


<% @search.results.each do |r| %>
<%= render :partial => ‘result’, :locals => {:result => r} %>
<%= render :partial => ‘result_divider’ %>
<% end %>

<%= render :partial => ‘result’, :collection => @search.results,
:spacer_template => ‘result_divider’ %>

_result.html looks like this:

<%= result[:url] %>

_result_divider.rhtml contains “


”.

If I remove the last render() call the page prints out the url field
separated by


's just like I’d expect. If I include that last
render()
call I get an error pointing to _result.html:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]

What I don’t understand is why the first works, but not the second since
my understanding is that first each() loop is really the same thing as
the
second render() call.

???

Thanks!

-philip