A little help before I go nuts please...
Steve Fairhurst
10 posts
|
I am following the book very closely and I am up to ITERATION C2 : A SMARTER CART (page 113). I have just made the changes to the add_to_cart.html.erb and I now get:
So I continued on and tried the “rake db:sessions:clear”, still get the error. I have been over and over the code and I can’t see whats wrong. Please put me right! |
Serban Porum...
5 posts
|
Hey Steve, I suspect the is the issue is in some other place. It’s strange that item is nil. Sprinkle a few of these (or whatever other messages you see fit) in your code and take a close look at the development.log file: RAILS_DEFAULT_LOGGER.debug ”#{@cart.inspect}” The debug statements will hopefully give you more insight into the problem. |
Steve Fairhurst
10 posts
|
Hi Serban, Thanks for the response, I am now going through the log but what would cause the nil object? |
Serban Porum...
5 posts
|
As I look at your message again, the “NoMethodError in Store#add_to_cart” is bothering me. Usually, there is more to that message—something along the lines of “undefined method nameOfMethodIcantFind”. Maybe some of the info here will help you track the problem down: |
Steve Fairhurst
10 posts
|
Thanks again Serban, I will have a look on Sunday when I finally get some time to figure it out. |
Steve Fairhurst
10 posts
|
Ok its working again, I changed: This To This And that sorted the problem! |
Serban Porum...
5 posts
|
Steve, I’m glad to hear that you’ve got things working again. In my opinion, the “h” shouldn’t have fixed anything. Please humor me when you have some time and remove the “h” you added. I suspect your app will still work. |
Steve Fairhurst
10 posts
|
OK now i’m really confused! You are correct the with or without the “h” it works now but this was the only amendment I made, so why on earth would it just suddenly decide to work! Bizarre! Thanks for your interest in this Serban, its very much appreciated. |
James West
70 posts
|
because you have re started the server? |
Serban Porum...
5 posts
|
When I replicated your problem (or something close to it) I also ran into a situation where the app continued to misbehave even after I fixed the error I introduced. I would need to take a closer look, but I think the session was somehow sticking around in memory (even after clearing them). I say this because the app would continue to fail at its “usual” url localhost:3000/store/add_to_cart/1, but work here 0.0.0.0:3000/store/add_to_cart/1. The localhost url version would work in a new browser (e.g., Firefox instead of Safari). Using a different url or launching in a different browser starts a new session, so again my thought is that the original session was sticking around. I should have mentioned this in addition to pointing you to that NoMethodError link, but I hesitated because I wasn’t actually able to get exactly the same error you had. I’ve never run into that sort of problem and had one of those “naw, that couldn’t be it” moments. In any case, have fun with the rest of the Depot app and the book :-).
|
Steve Fairhurst
10 posts
|
Serban, that makes sense actually I think you may have hit the nail on the head there. Thanks again. And yes I will enjoy the rest of the book. Cheers! |
11 posts, 3 voices
