On page 177 the book indicates that if you add the layout “store” call to the application controller, that the layout will be available application wide. I have found that this has no effect for me. I have cleared all sessons, restarted the server, yet no luck. When I place this call in each of the controllers separately, it works fine. What am I missing?
Did you remove the scaffold generated layouts, as described on page 178?
I am also having a problem with that. Ive removed scaffold generated layouts, but when i write the layout “store” line, i am getting an exception in the store.html.erb file. The error says: You have a nil object when you didn’t expect it! The error occurred while evaluating nil.items
and it says the problem is here: Extracted source (around line #14):
12: <div id="columns">
13: <div id="side">
14: <% hidden_div_if(@cart.items.empty?, :id=>”cart”) do %>
15: <%= render(:partial=>”cart”, :object=>@cart) %>
16: <% end %>
17: <%= link_to ‘Home’, :controller => ‘store’ %>
I just cant understand whats happening… I would appreciate any help cause iam stuck! Thanks anyway!
I’ll try to write it again:
11: </div> 12: <div id="columns"> 13: <div id="side"> 14: <% hidden_div_if(@cart.items.empty?, :id=>"cart") do %> 15: <%= render(:partial=>"cart", :object=>@cart) %> 16: <% end %> 17: <%= link_to 'Home', :controller => 'store' %><br/>
@Sean I had the same issue. Maybe my solution will work for you as well? See it here.
youre block should look like this:
`<!-- START_HIGHLIGHT --> <!-- START:hidden_div --> <% if @cart %> <!-- This is what's failing. There's no check in the text to see if the @cart is null --> <% hidden_div_if(@cart.items.empty?, :id => "cart") do %> <%= render(:partial => "cart", :object => @cart) %> <% end %> <% end %> `