04 Mar 2013, 00:40
Photo 22-02-12 3 02 49 p.m._pragsmall

Martin Miranda (3 posts)

Hello!

I’m getting an error when running the functional test after iteration D2.

I double checked and my code is the same as the book.

  1) Error:
test_should_destroy_product(ProductsControllerTest):
NameError: undefined local variable or method `lines_items' for #<Product:0x007fbb91be03d0>
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activemodel-3.2.12/lib/active_model/attribute_methods.rb:407:in `method_missing'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/attribute_methods.rb:149:in `method_missing'
    /Users/martin/Sites/depot/app/models/product.rb:20:in `ensure_not_referenced_by_any_line_item'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:407:in `_run__2906671944649054575__destroy__3841254726506670159__callbacks'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/callbacks.rb:254:in `destroy'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/transactions.rb:254:in `block in destroy'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transaction'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/transactions.rb:254:in `destroy'
    /Users/martin/Sites/depot/app/controllers/products_controller.rb:76:in `destroy'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:414:in `_run__2162135592192040906__process_action__1699009361154834475__callbacks'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/metal/testing.rb:17:in `process_with_new_base_test'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/test_case.rb:473:in `process'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/test_case.rb:49:in `process'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/actionpack-3.2.12/lib/action_controller/test_case.rb:405:in `delete'
    /Users/martin/Sites/depot/test/functional/products_controller_test.rb:54:in `block (2 levels) in <class:ProductsControllerTest>'
    /Users/martin/.rvm/gems/ruby-1.9.3-p385@rails32/gems/activesupport-3.2.12/lib/active_support/testing/assertions.rb:55:in `assert_difference'
    /Users/martin/Sites/depot/test/functional/products_controller_test.rb:53:in `block in <class:ProductsControllerTest>'

Thanks for you help!

04 Mar 2013, 01:52
Samr_small_pragsmall

Sam Ruby (584 posts)

Change lines_items to line_items in app/models/product.rb.

04 Mar 2013, 19:49
Photo 22-02-12 3 02 49 p.m._pragsmall

Martin Miranda (3 posts)

Thanks Sam! That fixed it.

  You must be logged in to comment