search for: display_cart

Displaying 20 results from an estimated 34 matches for "display_cart".

2006 Jun 23
3
Yet another problem with NoMethodError in Store#display_cart
...ad the same problem as I have, but there solutions doesn''t seems to work for me. I''m trying to do the depot example in the AWDwR book. But now I''m stock with a problem that I can''t solve. I get this error: <--- begin error here ---> NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #4 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.size Extracted source (around line #4): 1: <h1>Display Cart</h1> 2: 3: <...
2006 Apr 20
0
problem in "depot" app - cart contents not shown on checkout
...ated. I''m running Locomotive 1.0.0c on Tiger with MySQL from Apachefriends XAMPP. Here is a snippet of the log file, where I add an item to an empty cart and then show the order page. You can see where I noticed something odd below. It appears that the cart is not getting loaded in display_cart() when in the context of the order page: Processing StoreController#add_to_cart (for 127.0.0.1 at 2006-04-20 02:02:07) [GET] Session ID: 90352668088f989d5f939978b52b2a3a Parameters: {"action"=>"add_to_cart", "id"=>"4", "controller"=&gt...
2006 Aug 02
7
Same error ... again.
I reached page 82 of the Book "Agile Development with Rails" First Edition. After I compiled the code I got the following error message. [CODE] NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #11 raised: undefined method `product'' for 1099.0:Float 8: <table> 9: <% 10: for item in @items 11: product = item.product 12: -%> 13: <tr> 14: <td><%= item.quantity %></td> [CODE] My displ...
2006 Jul 27
2
Agile Web Development Problem
I am following that book, and I bump into this error in the Cart Creation Chapter. Can anyone help me? NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #6 raised: undefined method `product'' for 666.0:Float -- Posted via http://www.ruby-forum.com/.
2006 Jan 10
5
using dynamic element ids with visual_effect
...> The controlled sends down item_id as a header when the object gets added: def add_to_cart product = Product.find(params[:id]) item = @cart.add_product(product) if request.xhr? headers[''X-Item-Id''] = item.object_id render(:action => "display_cart", :layout => false) else redirect_to(:action => ''index'') end end I''d really like to use visual_effect() instead of having my own flash_cart method, but I can''t think of a way of giving it the element ID dynamically. Am I missi...
2005 Sep 02
4
Error has me stumped (Agile Web Dev with Rails book)
...he code that I downloaded from the book''s website. When I try to add an item to the cart (http://192.168.1.7:3000/store/add_to_cart/1) I get the following error: - - Unknown action No action responded to add_to_cart -- If I try to display the cart instead (http://192.168.1.7:3000/store/display_cart) I get this: -- Unknown action No action responded to display_cart -- As far as I can see everything I need is in place. Thanks, Tig
2006 Apr 18
1
''depot''app, trouble with session / cookies
Many of you probably know the ''depot'' app from the ''Agile Rails development'' book. When the view changes from ''Store'' to ''display_cart,'' a session containing the shopping-cart (:cart) is supposed maintain the ''cart'' between calls, but when the display_cart stub view shows up, I have always ZERO elements in the cart! I have received valuable help already, but the issue seems less understandable tha...
2006 Mar 05
3
"Undefined method" problem in "Agile Web Development With Rails"
Hi, I''m reading the "Agile Web Development With Rails" book. So long, everything has worked fine, but now I got this annoying error message that I just can''t understand. The error appears for me around page 87, chapter 8. NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #28 raised: undefined method `product'' for 2395.0:Float Extracted source (around line #28): 25: </tr> 26: <% 27: for item in @items 28: product = item.product 29: -%> 30: <tr> 31: <td><%= h(product.titl...
2006 Apr 16
9
''depot'' app, where''s session?
...oller about :cart and :line_item: model :cart model :line_item Here''s part of the Store_controller: def add_to_cart product = Product.find(params[:id]) @cart = find_cart @cart.add_product(product) #1# breakpoint "hallo" redirect_to(:action => ''display_cart'') end def display_cart @cart = find_cart @items = @cart.items end private def find_cart #2# session[:cart] ||= Cart.new end #1# At this breakpoint I can verify that the cart contains the correct product. There''s a difficulty with inspection, however: w...
2007 Aug 30
3
Rails - depot application
..."undefined method `product'' for #<BigDecimal:331ce70,''0.21E1'',8(8)> " "Extracted source (around line #9): 8: for item in @items 9: product = item.product 10: -%> 11: <tr> 12: <td><%= item.product%></td>" this is display_cart.rhtml line_item.rb has: "class LineItem < ActiveRecord::Base belongs_to :product def self.for_product(product) item = self.new item.quantity = 1 item.product = product item.unit_price = product.price end end " cart.rb has: "class Cart attr_reader :items attr_read...
2005 Dec 23
6
Agile book - test error
...ontroller_test.rb" The troublesome line is in the test below: def test_add_to_cart get :add_to_cart, :id => @version_control_book.id <<< cart = session[:cart] assert_equal @version_control_book.price, cart.total_price assert_redirected_to :action => ''display_cart'' follow_redirect assert_equal 1, assigns(:items).size assert_template "store/display_cart" end And the error n question is: 1) Error: test_add_to_cart(StoreControllerTest): RuntimeError: Called id for nil, which would mistakenly be 4 -- if you really wanted the...
2006 Aug 14
1
NoMethodError
...<td><%= h(product.title)%></td> <td align="right"><%=item.unit_price %></td> <td align="right"><%=item.unit_price * item.quantity %></td> </tr> <% end %> </table> I saw this message NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #5 raised: undefined method `product'' for 5.0:Float Extracted source (around line #5): 2: <table> 3: <% 4: for item in @items 5: product = item.product 6: %> 7: <tr> 8: <td><%= item.quantity %></td&g...
2006 Feb 07
11
Possible Rails Security Issue?
...Processing StoreController#checkout (for xxx.xxx.xxx.xxx at 2006-02-06 09:38:27) [GET] Parameters: {"action"=>"checkout", "controller"=>"store"} Rendering within layouts/store Rendering store/checkout Start rendering component ({:action=>"display_cart"}): Processing StoreController#confirm_order (for xxx.xxx.xxx.xxx at 2006-02-06 09:39:32) [POST] Parameters: {"commit"=>" Continue ", "action"=>"confirm_order", "payment"=>{"card_type"=>"M", "card_nu...
2007 Oct 19
14
Agile Web Development Book, need a bit of help
I''m working my way through the book Agile Web Development with Rails, and I am in the section where the book has me creating a display_cart method and the associated view. When I copied the code from the book into the view, it threw this error. If anyone could give me some hints where I should be looking I''d appreciate it. NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #5 raised: u...
2006 Feb 26
0
NoMethodError in Agile Web Devleopment Depot Tutorial
I''m working on building the shopping cart in the Depot tutorial in the Agile Web Development book. I''m at the part (about page 80) where you build the ability to add items to the cart. I''m able to get to /store/display_cart/ and it seems items are being added, but if I just click on a link to add an item (/store/add_to_cart/2) it gives me this: NoMethodError in Store#add_to_cart #{RAILS_ROOT}/app/models/cart.rb:10:in `add_product'' #{RAILS_ROOT}/app/controllers/store_controller.rb:11:in `add_to_cart'...
2006 Aug 07
2
Newbie question about adding product to cart
...39;', {:action => ''add_to_cart'', :id => product }, :class => ''addtocart'' %> def add_to_cart product = Product.find(params[:id]) @cart = find_cart @cart.add_product(product) redirect_to(:action => ''display_cart'') end In the link_to code, why isn''t :id set to product.id? In other words, shouldn''t it be :id => product.id ? I don''t understand why the whole product object is being hashed when the find method is only going to use the id value anyway. Thanks David...
2006 Aug 15
3
update or alter cart
I want to modify and update the items in the Depot - "display_cart". Since the cart is in a session, its a little hard to get at the data. I just want to create a way to change quantities, prices and recalculate. Has someone done this, and could you point me to the right direction. Thanks Chas -- Posted via http://www.ruby-forum.com/.
2006 Feb 12
0
no method error - you have a nil object....
...o add product with :id to the cart with redirect to display product = Product.find(params[:id]) @cart = find_cart # gets existing cart object or creates new one @cart.add_product(product) # add product method sits in the Cart class (in models) redirect_to(:action => ''display_cart'') end def display_cart @cart = find_cart @items = @cart.items end private # everything below here is private. any public actions need to be above this part of the class def find_cart # creates a new cart session object if one doesn''t exist pg 81 @cart...
2006 Jan 30
2
Cannot see what I have done wrong.
...wired together the other bits in app/controllers/store_controller.rb and app/models/line_item.rb class StoreController < ApplicationController def add_to_cart product = Product.find(params[:id]) @cart = find_cart @cart.add_product(product) redirect_to(:action => ''display_cart'') end def display_cart @cart = find_cart @items = @cart.items end def index @products = Product.salable_items end private def find_cart session[:cart] ||= Cart.new end end ~ "app/controllers/store_controller.rb" ******* class LineItem < Acti...
2006 Apr 11
2
Extending Depot Example
Hi I am new to the whole Rails/Ruby world as having come from a MS .NET background, but I have followed the Depot example in the Agile Web Dev. with Rails book with relative ease. However as an exercise to see how much I had understood, I thought I would attempt to modify the example a bit and add a Quantity field to the store index so as to pass that value into the cart. I have extended the