Agile Web Development with Rails - Chapter 8, Task C, Error

I am currently in Chapter 8, Task C, Cart Creations. On pages 110 and
111, it shows modifications needed to be made to the following files:

app/controllers/store_controller.rb
app/views/store/add_to_cart.rhtml
app/models/cart.rb

When I make the changes and refresh my browser, I get an error message,
“No method error in store#add_to_cart”. I have defined the total_price
method in my cart.rb file, so I fail to see where the error about there
not being a method entitled total_price comes up at. Has anyone else
had this trouble?

Help is appreciated.

Hi, could you tell me the following:

Windows XP? Mac OS X?
Ruby Version?
Rails Version?

-Conrad

Hi Kenny, you can also try comparing your code with the code download
for your version of the AWDwR.

Good luck,

-Conrad

Conrad T. wrote:

Hi Kenny, you can also try comparing your code with the code download
for your version of the AWDwR.

Good luck,

-Conrad

Thanks. Tried this. Even tried overwriting the code based on what was
in specific “depot” files. Still didn’t work.

On Jan 3, 2007, at 7:56 AM, Kenny Mr wrote:

Thanks. Tried this. Even tried overwriting the code based on what
was in specific “depot” files. Still didn’t work.

Did you clear out the session and restart the application?

Kenny Mr wrote:

I am currently in Chapter 8, Task C, Cart Creations. On pages 110 and
111, it shows modifications needed to be made to the following files:

app/controllers/store_controller.rb
app/views/store/add_to_cart.rhtml
app/models/cart.rb

When I make the changes and refresh my browser, I get an error message,
“No method error in store#add_to_cart”. I have defined the total_price
method in my cart.rb file, so I fail to see where the error about there
not being a method entitled total_price comes up at. Has anyone else
had this trouble?

Help is appreciated.

Could you please post the full error message ?

Alan

Kenny Mr wrote:

not being a method entitled total_price comes up at. Has anyone else
had this trouble?

Help is appreciated.

If you read further down 111 you will see that he shows that error to
be expected. He then shows you the importance of paying attention to
session data. To clear the error you are to run:
rake db:session:clear

Conrad T. wrote:

Hi, could you tell me the following:

Windows XP? Mac OS X?
Ruby Version?
Rails Version?

-Conrad

Windows XP - Home Edition
Ruby 1.8.5
Rails 1.1.6

[email protected] wrote:

Kenny Mr wrote:
rake db:session:clear

typo, should be sessions not session:
rake db:sessions:clear

Dave T. wrote:

On Jan 3, 2007, at 7:56 AM, Kenny Mr wrote:

Thanks. Tried this. Even tried overwriting the code based on what
was in specific “depot” files. Still didn’t work.

Did you clear out the session and restart the application?

No. At this point, I was at the end of the chapter. It was Iteration
C4, Finishing the Cart. Just updated the files as the book stated, then
launched Webrick and refreshed my browser.

Kenny Mr wrote:

Dave T. wrote:

On Jan 3, 2007, at 7:56 AM, Kenny Mr wrote:

Thanks. Tried this. Even tried overwriting the code based on what
was in specific “depot” files. Still didn’t work.

Did you clear out the session and restart the application?

No. At this point, I was at the end of the chapter. It was Iteration
C4, Finishing the Cart. Just updated the files as the book stated, then
launched Webrick and refreshed my browser.

def total_price
@total_price = 0
@items.each { |item| @total_price += item.price }
@total_price
end

Was able to track this down just a little earlier. I made these changes
in cart.rb in app/models. Finally was able to display it correctly.