Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > BOOK: Beginning Ruby on Rails
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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!
  #2 (permalink)  
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)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:50 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.