Note that there are some explanatory texts on larger screens.

plurals
  1. POTest Failure: ActionView::Template::Error: undefined method `title' for nil:NilClass
    text
    copied!<p>This is in my _line_items.text.erb file:</p> <pre><code>&lt;%= sprintf("%2d x %s", line_item.quantity, truncate(line_item.product.title, length: 50)) %&gt; </code></pre> <p>orders.yml</p> <pre><code>one: name: Dave Thomas address: MyText email: dave@example.org pay_type: Check </code></pre> <p>line_items.yml</p> <pre><code>one: product: ruby cart_id: 1 order: one two: product_id: 1 cart_id: 1 order: one </code></pre> <p>products.yml</p> <pre><code>ruby: title: Programming Ruby 1.9 description: Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programsdelivered fast, you should add Ruby to your toolbox. price: 49.50 image_url: ruby.png </code></pre> <p>This all seems to be correct.</p> <p>Here is the actual test:</p> <pre><code>class OrderNotifierTest &lt; ActionMailer::TestCase test "received" do mail = OrderNotifier.received(orders(:one)) assert_equal "Pragmatic Store Order Confirmation", mail.subject assert_equal ["dave@example.org"], mail.to assert_equal ["depot@example.com"], mail.from assert_match /1 x Programming Ruby 1.9/, mail.body.encoded end </code></pre> <p>Any ideas on where else to look for the <code>ActionView::Template::Error: undefined method 'title' for nil:NilClass</code> error?</p> <p>Update:</p> <pre><code>class LineItem &lt; ActiveRecord::Base attr_accessible :cart_id, :product_id, :quantity, :order_id, :product, :cart, :price belongs_to :order belongs_to :cart belongs_to :product def total_price self.price * self.quantity end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload