Wrox Programmer Forums
|
BOOK: Beginning Ruby on Rails
This is the forum to discuss the Wrox book Beginning Ruby on Rails by Steve Holzner Ph.D.; ISBN: 9780470069158
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Ruby on Rails section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2009, 12:36 AM
Registered User
 
Join Date: May 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 7: Store total error

I'm trying to get the display_cart function to properly total up the purchases and when I follow either the book or the downloaded code, I get the following error:

NoMethodError in BuyController#display_cart
undefined method `total' for #<Cart:0x1a327fc>

I've isolated the issue to the following area:

Code:
	def display_cart
		@cart = get_cart
		@purchases = @cart.purchases
		@total = @cart.total
	end
When I replace @total = @cart.total with @total = @cart.price (I know that it isn't going to work) it displays the display cart view properly, sans the total. It seems the @total += item.price in

Code:
def add_purchase(item)
		appendFlag = true
		for purchase in @purchases
			if (item.id == purchase.item.id)
				appendFlag = false
				purchase.quantity += 1
		end
	end		
	if(appendFlag)
		@purchases << Purchase.buy_one(item)
	end
	@total += item.price
	end
I am using Ruby 1.8.2 on Leopard (that's caused other errors) if it matters.

I'm sure it's very simple but I could use some extra help!
 
Old May 30th, 2009, 06:21 PM
Registered User
 
Join Date: May 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default actually using Ruby 2.x

just looked again and I'm using Ruby 2.x (not sure)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
CH 9 Error manasa BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 February 23rd, 2007 07:01 PM
store and process error messages Hylsan PHP Databases 7 December 20th, 2006 08:40 AM
ch.4 - I do not get the compilation error dad62896 BOOK: Beginning ASP.NET 1.0 2 February 11th, 2005 04:20 AM
Error about store procedure for Shopping.aspx Blueman137 ASP.NET 1.0 and 1.1 Basics 0 February 8th, 2004 05:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.