Hello! I am working my way through the Agile Web Development guide on
RoR (the depot application).
I am a bit lost as to where to debug the following error. The error is
pasted below:
===============================================================================================
NameError in Store#add_to_cart
undefined local variable or method `product'' for LineItem:Class
RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
`method_missing''
#{RAILS_ROOT}/app/models/line_item.rb:7:in `for_product''
#{RAILS_ROOT}/app/models/cart.rb:11:in `add_product''
./script/../config/../app/controllers/store_controller.rb:10:in
`add_to_cart''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
`method_missing''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
`perform_action_without_filters''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
`perform_action''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`process_without_session_management_support''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
`process''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service''
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require''
script/server:3
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
`method_missing''
#{RAILS_ROOT}/app/models/line_item.rb:7:in `for_product''
#{RAILS_ROOT}/app/models/cart.rb:11:in `add_product''
./script/../config/../app/controllers/store_controller.rb:10:in
`add_to_cart''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
`perform_action_without_filters''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
`perform_action_without_benchmark''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
`perform_action''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`process_without_session_management_support''
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
`process''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service''
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require''
script/server:3
Request
Parameters: {"id"=>"2"}
Show session dump
---
:cart: !ruby/object:Cart
items: []
total_price: 0.0
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
===============================================================================================
So I am assuming that there is a problem with the variable
''product'',
but I am having trouble finding it. I don''t want to bombard you with
code, but any direction would be helpful.
--
Posted via http://www.ruby-forum.com/.