James Giannini
2006-Jul-26 04:09 UTC
[Rails] 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... <html> <head> <title>The Yay Area Online Book Store</title> <%= stylesheet_link_tag "depot", :media => "all" %> <%= javascript_include_tag :defaults %> </head> <body id= "store"> <div id= "banner"> <img src="http://www.artima.com/images/pragmatic.jpg"/> <%= @page_title || "Bo Rizzle''s bookshelf" %> </div> <div id="columns"> <div id="side"> <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> </html> 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 -- Posted via http://www.ruby-forum.com/.
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> > <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> > </html> > > > 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >