small medium large xlarge

10 Jun 2008, 17:46
Jason Black (1 post)

The business about making the store layout the default layout for the application is sequenced oddly, in such a way as to generate some confusing errors that aren’t mentioned in the text.

If the instructions are followed in the order that the book lists them, then when the user visits localhost:3000/users immediately after putting the layout “store” instruction in application.rb, you get a route error (or at least, I got a route error doing this on Windows).

The text should say to remove to unnecessary products.html.erb and users.html.erb BEFORE telling the user to go look at either of those controllers.

Also–although I’m sure you know this–the illustrations for that section need to be fixed because the browser screenshots in them show the wrong URLs, which was also quite confusing for me until I remembered the note at the front of the book saying not to trust the illustrations.

11 Jun 2008, 14:07
Sam Ruby (633 posts)

Help me understand where the instructions aren’t clear. Here’s the current text:

bq. Now if we visit http://localhost:3000/admin we see the familiar Pragmatic Bookshelf banner and sidebar. But if we visit http://localhost:3000/users we do not. It turns out that there is one more thing that we need to do: we need to stop the generated scaffolding from overriding the application default layout. And nothing could be easier. We simply need to remove the generated layouts, and refresh.

This text says that if you visit /users you will see a problem, and what the solution to that problem is.

What am I missing?

25 Jun 2008, 21:49
Breno Gazzola (1 post)

I think that the problem is, if we visit the admin page immediately after setting the store layout, we will get the following error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.items

Extracted source (around line #25): 

22:     <div id="side">
23:       <!-- START_HIGHLIGHT -->
24:       <!-- START:hidden_div -->
25:       <% hidden_div_if(@cart.items.empty?, :id => "cart") do %>
26:         <%= render(:partial => "cart", :object => @cart) %>
27:       <% end %>
28:     <!-- END:hidden_div -->

This is because the hidden cart div is still trying to .items when there is no @cart present. If we look for a solution in the text on the same page we will find this:

bq. Now all we need to do is to prevent the hidden cart div from being present at all for functions where there is no cart, and to add links to the various administration functions to the sidebar in the layout(…)

However it’s never explained how do we prevent the cart div from being present, only how to add the links.

27 Jun 2008, 08:19
Sam Ruby (633 posts)

The next beta will have little triangles pointing at the

<% if @cart %>


<% end %>

lines in the “depot_q/app/views/layouts/store.html.erb”: file excerpt that immediately follows that paragraph. I apologize for the omission.

You must be logged in to comment