Forum: Ruby on Rails instance variable attributes() method in tests fixtures

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2007-05-22 17:11
as stated in Rails Book example , I have a fixtures file  orders.yml

valid_order_for_fred:
id: 1
name: Fred
email_address: fred@flinstone;com

in my controller test file,  I tried :
fixtures :orders
def test_save_valid_order
post :save_order, :order => @valid_order_fo_fred.attributes

but I get an error

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.attributes
    test/functional/orders_controller_test.rb:65:in
`test_save_valid_order'
This topic is locked and can not be replied to.