![]() | P125 - error on clicking 'add to cart' btn |
|
19 May 2010, 22:55
Stuart Cullum (2 posts) |
I get: NameError in Line itemsController#create undefined local variable or method `product_id’ for # app/controllers/line_items_controller.rb:45:in `create’ Not sure where I’ve gone wrong. Any ideas? Many thanks, s. |
|
20 May 2010, 11:42
Sam Ruby (549 posts) |
On page 124, you added a line to the line_items_controller. That line is supposed to reference the |
|
20 May 2010, 20:42
Stuart Cullum (2 posts) |
Ahh! ... Thanks for your time Sam. s. |
|
05 Jul 2010, 21:02
David Stys (2 posts) |
Hi Sam, Loving the book so far, but just got stuck on page 121 of b5_0.pdf Similarly to the previous post: ArgumentError in Line itemsController#create wrong number of arguments (0 for 1) Application Trace | Framework Trace | Full Trace Parameters: {“product_id”=>”2”,
“authenticity_token”=>”NnhbaGSOoKuJsEn0ccGUHbJp/vclIv4vFz7t/MOGGCo=”} Any help would be fantastic – thanks! Dave |
|
05 Jul 2010, 23:26
David Stys (2 posts) |
Aha! I had the following typo in my cart model… has_many :line_items, :dependent => destroy Which needs to be: has_many :line_items, :dependent => :destroy (Notice, the ”:” was missing at my destroy dependency…) Thanks—I’m enjoying your book tremendously. I’m VERY new to Ruby and new to Rails, but I’m catching on fairly quickly. The book is easy to follow. Dave |
|
23 Jul 2011, 11:25
Steve Chen (2 posts) |
Thank you David Stys. I made the exact mistake… couldn’t figure it out for days… the error message certain didn’t help… |
|
07 Jul 2012, 13:57
Jack Sutherland (1 post) |
Wow! David, I just pulled my hair out for the last 2 hours trying to figure this out. Glad I found your comment. |
| You must be logged in to comment |

