0

My cart model contain line_items. I am working in a cart view.

In a view if i do :

<%= render cart.line_items%>

The _line_item.html.erb partial is rendered. To use another partial, it need a more verbose syntax of render. Before trying to use another partial I want to call my current partial like this :

<%= render :partials => "line_items/_line_item", :collection => cart.line_items %>

It does not work, here is the error :

undefined method `formats' for nil:NilClass

I have tried with and without underscore and a few other syntax. What is wrong in this partial call?

Syl
  • 3,719
  • 6
  • 35
  • 59

1 Answers1

1

You need to call the partial with:

<%= render :partial => "line_items/line_item", :collection => cart.line_items %>

if you partial is called _line_item.html.erb in line_items folder.

Matteo Alessani
  • 10,264
  • 4
  • 40
  • 57