![]() | 'nil' is not an ActiveModel-compatible object that returns a valid partial path. |
|
23 Nov 2012, 00:57
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
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. 19: 20: 21: 22: <%= render @cart %> 23: 24:
25: Rails.root: C:/rails/depot Application Trace | Framework Trace | Full Trace |
|
23 Nov 2012, 01:00
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
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
peter qp (2 posts) |
alternatively, add
@cart = current_cart
to order_controller, def create |
| You must be logged in to comment |

