NoMethodError in CartsController#destroy - Agile Web Development with Rails 4
问题 I'm learning Rails following the book Agile Web Development with Rails 4 and I got stuck with this Error: NoMethodError in CartsController#destroy undefined method `name' for nil:NilClass This is the action Destroy of the Cart controller. The error info references to the line @cart.destroy if @cart.id == session[:cart_id] : # DELETE /carts/1 # DELETE /carts/1.json def destroy @cart.destroy if @cart.id == session[:cart_id] session[:cart_id] = nil respond_to do |format| format.html { redirect