bunnahabhain

bunnahabhain

Agile Web Development with Rails 8: B6.0(page 126)

Code shows:

@line_item = @cart.line_items.build(product: product)

This produces an error of " * Product must exist" when you press the “Add to Cart” button.

However, if I change the line to add “.id” to product, then it works as expected:

@line_item = @cart.line_items.build(product_id: product.id)

0 48 2

Marked As Solved

bunnahabhain

bunnahabhain

I have resolved the issue by recreating the depot app from the beginning. I had been avoiding doing so as I was following along with each beta release of the book, and had been building upon the chapters that I had already completed.

I have a feeling that it might have simply been an issue with a bad record in the database, as I recall pressing the “new product” button before completing the code that went along with the button. Unfortunately, I had dropped and recreated the database before I thought to take a look at it.

Please consider this issue closed. Thanks!

Where Next?

Popular Pragmatic Bookshelf topics Top

brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
2 1374 2
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
4 1191 4
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
1 4071 2
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
4 2354 3
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
5 1334 4
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
1 1179 3
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
0 1148 3
New
fynn
This is as much a suggestion as a question, as a note for others. Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
0 1287 2
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
3 1150 19
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
1 974 3
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
36 6636 11
New
AstonJ
Or looking forward to? :nerd_face:
480 9438 251
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
51 4319 20
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
177 8632 77
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
88 5364 32
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
110 3900 43
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
91 5152 43
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
13 3957 4
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
4 3745 1
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
72 3959 21
New

Sub Categories: