i'm working through the cart example in agile webdev with rails and i've hit a snag.

i was able to get the cart to display the quantity of products selected via the stub.

however, when i was supposed to update the stub (after updating the ApplicationController to see the cart and line_item models), i got an error message.

i double checked my code and found an error, but it didn't ultimately resolve the issue.

the error i'm getting is...

Code:
 NoMethodError in Store#display_cart

Showing app/views/store/display_cart.rhtml where line #10 raised:

You have a nil object when you didn't expect it!
The error occured while evaluating nil.title

Extracted source (around line #10):

7: -%>
8:   <tr>
9:     <td><%= item.quantity %></td>
10:     <td><%= h(product.title) %></td>
11:     <td align="right"><%= item.unit_price %></td>
12:     <td align="right"><%= item.unit_price * item.quantity %></td>
13:   </tr>

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/store/display_cart.rhtml:10:in `_run_rhtml_store_display_cart'
#{RAILS_ROOT}/app/views/store/display_cart.rhtml:5:in `_run_rhtml_store_display_cart'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:314:in `compile_and_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:290:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:249:in `render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:699:in `render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:621:in `render_with_no_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/layout.rb:243:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:53:in `render'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:53:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:911:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle_dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
script/server:3

#{RAILS_ROOT}/app/views/store/display_cart.rhtml:10:in `_run_rhtml_store_display_cart'
#{RAILS_ROOT}/app/views/store/display_cart.rhtml:5:in `_run_rhtml_store_display_cart'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:314:in `compile_and_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:290:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:249:in `render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:699:in `render_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:621:in `render_with_no_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/layout.rb:243:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:53:in `render'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:53:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:911:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle_dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
script/server:3

Request

Parameters: None

Show session dump

--- 
:cart: !ruby/object:Cart 
  items: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
    product: 
  - !ruby/object:LineItem 
    attributes: 
      quantity: 0
      product_id: 
      unit_price: 
    new_record: true
  - !ruby/object:LineItem 
    attributes: 
      quantity: 1
      product_id: 3
      unit_price: 24.95
    new_record: true
    product: !ruby/object:Product 
      attributes: 
        image_url: /images/ror.png
        date_available: "2006-05-20"
        price: "24.95"
        title: Agile Web Development with Rails
        id: "3"
        description: This book describes how to program in an agile manner using Ruby on Rails.  Ruby is an object oriented programming language and Rails is a framework.  It takes a while to convert from procedural thinking, but, once you do, application development becomes much more efficient.
  - !ruby/object:LineItem 
    attributes: 
      quantity: 1
      product_id: 2
      unit_price: 10.0
    new_record: true
    product: !ruby/object:Product 
      attributes: 
        image_url: /images/sk_auto_big.jpg
        date_available: "2006-05-13"
        price: "10.00"
        title: Product 2
        id: "2"
        description: Product 2
  - !ruby/object:LineItem 
    attributes: 
      quantity: 1
      product_id: 2
      unit_price: 10.0
    new_record: true
    product: !ruby/object:Product 
      attributes: 
        image_url: /images/sk_auto_big.jpg
        date_available: "2006-05-13"
        price: "10.00"
        title: Product 2
        id: "2"
        description: Product 2
  total_price: 284.6
flash: !map:ActionController::Flash::FlashHash {}


Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
i would appreciate any help to resolve this isssue.