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”
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/controllers/orders_controller.rb:58:in block (2 levels) in create’
I think the problem here is that cart object is nil. but I can’t figure out why it becomes nil.
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.
@cart = current_cart
to order_controller, def create