I have trouble to understand the difference between
<%= render :partial => "book", :object => @book %>
and
<%= render :partial => "book", :collection => @books %>
and
<%= render :partial => "book", :locals => { :book => @book } %>
Can someone explain it to me ?
These are the same:
They will render the
_book.html.erbfile once, and the @book object will be available in that partial as thebookvariable.Here is a sweet way to abbreviate the same thing:
This one is a little different:
It will render the
_book.html.erbfile once per book in@books, each in turn becoming available in that partial as thebookvariable.Here is a sweet way to abbreviate the same thing: