By Rupert
Rails Note #7: NIL in Fixtures
If you want user_id to be ‘nil’, then omit it from your fixtures. I tried setting user_id: nil before, and it turned out to be ’0′ in the database.
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html <% u = UserLogin.create( :password => 'foo') %> <% u.password=('password') %> user_no_profile: email: noprofile@yahoo.com admin: false user_id: nil salt: <%= u.salt %> salted_password: <%= u.salted_password %>

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html <% u = UserLogin.create( :password => 'foo') %> <% u.password=('password') %> user_no_profile: email: noprofile@yahoo.com admin: false salt: <%= u.salt %> salted_password: <%= u.salted_password %>

Before pulling your hair out on what went wrong with your functional tests, check the test database if you have the correct values in your records. Remember ’0′ is different from ‘nil’.
| Print article | This entry was posted by rupert on November 18, 2008 at 6:19 pm, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can skip to the end and leave a response. Pinging is currently not allowed. |