
ncr
Agile Web Development with Rails 6: LineItem
Hi,
Newbie here trying to learn Ruby on rails with AWDR6. Got a question regarding the LineItem scaffolded as part of Iteration D2: Connecting Products to Carts. What additional value does it provide? Is it just a join table for the many to many relationship between products and carts? But then a has_many association was used instead of has_many: through or has_many_and_belongs to as per docs. I am struggling to understand this bit of the tutorial as I do not get the underlying logic so any help will be highly appreciated
Most Liked

davetron5000
In theory if the join table doesn’t do more than just connect two tables, you are right, you probably would not need to create a model class for it. Iteration D2 doesn’t really foreshadow this, but in Iteration E1, we add a quantity to the line item, and this is a good example of why you’d make a model for the join table - to add metadata about the many-to-many relationship itself.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /c
- /julia
- /slackware
- /neovim