Something is wrong with this peice of code

<% if @cart.items.empty? %>

|^|^|^|^|^|^|^|^|^|^|^|^|^|

This peice of code is having a problem in the store.rhtml of my
application but i have no idea why… it says that it is and (extracted
source… here is the Store.rhtml… this is from an application made in
“Ruby on Rails” and it wont tell me how to fix it… iv done everything
in the book the exact way its told me, and there was an error…

The Yay Area Online Book Store <%= stylesheet_link_tag "depot", :media => "all" %> <%= javascript_include_tag :defaults %>
<%= @page_title || "Bo Rizzle's bookshelf" %>
		<div id= "cart"

--------------> <% if @cart.items.empty? %>
style=“display: none”
<% end %>

		<%= hidden_div_if(@cart.items.empty?, :id => "cart") %>
			<%= render(:partial => "cart", :object => @cart) %>
		</div>

			<a href="http://www....">Home</a><br />
			<a href="http://www..../faq">Questions</a><br />
			<a href="http://www..../news">News</a><br />
			<a href="http://www..../contact">Contact</a><br />
		</div>
		<div id="main">
			<% if flash[:notice] -%>
		<div id="notice"><%= flash[:notice] %></div>
	<% end -%>
			<%= @content_for_layout %>
		</div>
	</div>
	<% if flash[:notice] -%>
		<div id="notice"><%= flash[:notice] %></div>
	<% end -%>
</body>

If you could help me on this that would be so awsome… i just started
reading “Ruby on Rails” a little while ago… im on chapter 10 still
learning, so im kind of a newbie…

thanks. James

On Wed, Jul 26, 2006 at 06:08:58AM +0200, James Giannini wrote:

“Ruby on Rails” and it wont tell me how to fix it… iv done everything
in the book the exact way its told me, and there was an error…

Tell us what the error is ?

  	<div id= "cart"

--------------> <% if @cart.items.empty? %>
style=“display: none”
<% end %>

  	<%= hidden_div_if(@cart.items.empty?, :id => "cart") %>
  		<%= render(:partial => "cart", :object => @cart) %>
  	</div>

Your <div id=“cart” doesn’t have a closing > and will therefore not be
valid HTML; and therefore cannot be updated later.

If you think that it’s the evaluation of @cart.items.empty? that’s
wrong, I suggest you put a breakpoint in just before the div line
<% breakpoint “is @cart.items empty?” %>

and run script/breakpoint in one window while making a web request to
that page in another; before the page finished rendering you’ll see an
interactive ruby session in your breakpointer, and you can type in
@cart.items.empty?” (and a few other things too) to see if the value
really is set or not.

-jim

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs