Can 'locals' be used with 'collection' when rendering partials in Rails?

Like the guides said, specify the :as option in the call to the partial

enter image description here


What version are you using? Using my 2.3.5 I'm able to do just that:

render :partial => "/site_articles/article", :collection => @site_articles, :locals => { :footer => true }

, which you can find explained in other places, such as 3.4.6 of this.


For Rails 4.x, if you pass the collection directly to render (which you must do if you want to use automatic partial selection for a heterogeneous collection), the next parameter is interpreted as a hash of locals.

Try the following:

= render @enquiry.available_car_types, :path => customers_enquiry_path