17 Oct 2010, 23:45
Img_proxy.php_pragsmall

Yasuo Honda (4 posts)

Hi, I’m learning Rails 3 with beta 9.1 edition. Everything is good.

On page 191, When functional test for notifier get 2 errors.

yahonda@myorails3:~/work/depot$ rake db:test:load
(in /home/yahonda/work/depot)
yahonda@myorails3:~/work/depot$ ruby -I test test/functional/notifier_test.rb
Loaded suite test/functional/notifier_test
Started
EE
Finished in 0.470602 seconds.

  1) Error:
test_order_received(NotifierTest):
ActionView::Template::Error: undefined method `title' for nil:NilClass
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/whiny_nil.rb:48:in `method_missing'
    /home/yahonda/work/depot/app/views/line_items/_line_item.text.erb:3:in `_app_views_line_items__line_item_text_erb__1013695037_92633780_523522946'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:135:in `block in render'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:54:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:127:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:261:in `block in collection_with_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_collection.rb:430:in `block in method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_proxy.rb:216:in `block in method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_proxy.rb:216:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_proxy.rb:216:in `method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_collection.rb:430:in `method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:258:in `collection_with_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:241:in `render_collection'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:218:in `block in render'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `block in instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:216:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:334:in `_render_partial'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:31:in `render'
    /home/yahonda/work/depot/app/views/notifier/order_received.text.erb:7:in `_app_views_notifier_order_received_text_erb__107231134_92415270__636161364'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:135:in `block in render'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:54:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:127:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:59:in `block in _render_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `block in instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:56:in `_render_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:26:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:114:in `_render_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:108:in `render_to_body'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:101:in `render_to_string'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:92:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/deprecated_api.rb:111:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:710:in `block in collect_responses_and_parts_order'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:725:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:725:in `block in each_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:720:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:720:in `each_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:706:in `collect_responses_and_parts_order'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:648:in `mail'
    /home/yahonda/work/depot/app/mailers/notifier.rb:12:in `order_received'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/base.rb:150:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/base.rb:119:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:40:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/old_api.rb:75:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:446:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:441:in `initialize'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:425:in `new'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:425:in `method_missing'
    test/functional/notifier_test.rb:5:in `block in <class:NotifierTest>'

  2) Error:
test_order_shipped(NotifierTest):
ActionView::Template::Error: undefined method `title' for nil:NilClass
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/whiny_nil.rb:48:in `method_missing'
    /home/yahonda/work/depot/app/views/line_items/_line_item.html.erb:7:in `_app_views_line_items__line_item_html_erb___211472781_92946010_523522946'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:135:in `block in render'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:54:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:127:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:261:in `block in collection_with_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_collection.rb:430:in `block in method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_proxy.rb:216:in `block in method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_proxy.rb:216:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_proxy.rb:216:in `method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.1/lib/active_record/associations/association_collection.rb:430:in `method_missing'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:258:in `collection_with_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:241:in `render_collection'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:218:in `block in render'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `block in instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:216:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/partials.rb:334:in `_render_partial'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:31:in `render'
    /home/yahonda/work/depot/app/views/notifier/order_shipped.html.erb:7:in `_app_views_notifier_order_shipped_html_erb___937858975_92923410__636161364'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:135:in `block in render'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:54:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/template.rb:127:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:59:in `block in _render_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `block in instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/notifications.rb:52:in `instrument'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:56:in `_render_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_view/render/rendering.rb:26:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:114:in `_render_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:108:in `render_to_body'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:101:in `render_to_string'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:92:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/deprecated_api.rb:111:in `render'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:710:in `block in collect_responses_and_parts_order'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:725:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:725:in `block in each_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:720:in `each'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:720:in `each_template'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:706:in `collect_responses_and_parts_order'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:648:in `mail'
    /home/yahonda/work/depot/app/mailers/notifier.rb:23:in `order_shipped'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/base.rb:150:in `process_action'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/base.rb:119:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/abstract_controller/rendering.rb:40:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/old_api.rb:75:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:446:in `process'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:441:in `initialize'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:425:in `new'
    /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-3.0.1/lib/action_mailer/base.rb:425:in `method_missing'
    test/functional/notifier_test.rb:13:in `block in <class:NotifierTest>'

2 tests, 0 assertions, 0 failures, 2 errors, 0 skips

Test run options: --seed 12042

This error also happens when sqlite3 is used. Then I’ve found product_id column value is always 0

yahonda@myorails3:~/work/depot$ rails db test -p

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Oct 17 19:35:18 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> select id,product_id from line_items;

	ID PRODUCT_ID
---------- ----------
 980190962	    0
 298486374	    0

SQL> 
SQL> select id from products;

	ID
----------
 207281424
 298486374
 980190962

SQL> 

I expect product_id value should be some positive value generated by the sequence. Anyone got same errors?

Thanks,

18 Jan 2011, 23:41
5380_100123083666_592778666_2149911_8375185_s_pragsmall

Michael Joseph Kramer (1 post)

If you delete the “_id” suffix from the “product_id” and “cart_id” lines in test/fixtures/line_items.yml, it should fix your errors. HTH!

29 Mar 2012, 18:44
Img_proxy.php_pragsmall

Yasuo Honda (4 posts)

Thanks for the info. It’s been a long time since last time I’ve log in this discussion page.

12 Feb 2014, 16:53
Generic-user-small

David Kuhta (1 post)

Still valid 2 years later, gave me the hint to take another look at my fixtures. doffs cap Thanks

  You must be logged in to comment