views:

151

answers:

3

If we want to pass a collection to partial, we do like this:

<%= render :partial => "post", :collection => @posts %>

If we want to pass a single object within a custom variable, we do this:

<%= render :partial => "item", :locals => { :item => @advertisement } %>

Now what should I do to to pass a collection, "proxying" it through a custom variable (like the second case)?

+1  A: 

You can make use of the other way of calling partials:

render(:partial => 'post', :object => @posts)
tadman
Hmm, never seen the :member argument... any docs?
gmile
My bad, it's actually :object, but the same thing applies.It's in the RDoc documentation for Rails: http://apidock.com/rails/ActionController/Base/render
tadman
+1  A: 

Just pass it through locals like in your second example

<%= render :partial => "item", :locals => { :posts => @posts } %>
Mike Buckbee
+1  A: 

I found using :as parameter much more clear:

<%= render :partial => "item", :collection => @rabbits, :as => :item %>
gmile