It may happen because cart item model do not save product_id.
1) First, add validation to LineItem model. It will not solve issue, but you will be sure that issue is related with product_id.
validates :product_id, presence: true
2a) Update controller to play with Rails 4 strong parameters: http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html
2b) Or use Rails 3 while learning Ruby On Rails.
UPDATE.
You should also remove previous LineItem records from DB using rails console, otherwise you will still see this error, because old LineItems not associated with Product.