23 Nov 2012, 00:57
Generic-user-small

w paul (3 posts)

In task G, when place the order without writing user information. I got this err “‘nil’ is not an ActiveModel-compatible object that returns a valid partial path.” It suppose I should get some information like “Name can’t be blank”

23 Nov 2012, 00:58
Generic-user-small

w paul (3 posts)

Showing C:/rails/depot/app/views/layouts/application.html.erb where line #22 raised:

‘nil’ is not an ActiveModel-compatible object that returns a valid partial path. Extracted source (around line #22):

19: <div id="columns"> 20: <div id="side"> 21: <div id = "cart"> 22: <%= render @cart %> 23: </div> 24: <ul> 25: <li>Home</li> Rails.root: C:/rails/depot

Application Trace | Framework Trace | Full Trace app/views/layouts/application.html.erb:22:in _app_views_layouts_application_html_erb__704862158_33396480' app/controllers/orders_controller.rb:58:in block (2 levels) in create’ app/controllers/orders_controller.rb:51:in `create’

23 Nov 2012, 01:00
Generic-user-small

w paul (3 posts)

I think the problem here is that cart object is nil. but I can’t figure out why it becomes nil.

09 Dec 2012, 03:42
Generic-user-small

peter qp (2 posts)

on application layout, do you have this surrounding the partial?

<% if @cart %> #<-- the juice <%= hidden_div_if(@cart.line_items.empty?, id: 'cart') do %> <%= render @cart %> <% end %> <% end %> it basically tests for nil

I missed it because I’m skipping the tests sections. It’s in the Ajax chapter.

09 Dec 2012, 04:03
Generic-user-small

peter qp (2 posts)

alternatively, add

@cart = current_cart

to order_controller, def create

  You must be logged in to comment