Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created November 5, 2009 20:47
Show Gist options
  • Save jhsu/227362 to your computer and use it in GitHub Desktop.
Save jhsu/227362 to your computer and use it in GitHub Desktop.
Factory.define :event_pool do |p|
p.name "Some event pool"
end
$: RAILS_ENV=test script/console
>> Factory(:user)
ActiveRecord::StatementInvalid: PGError: ERROR: null value in column "user_id" violates not-null constraint
: INSERT INTO "event_pools" ("name", "created_at", "updated_at", "user_id") VALUES(E'Some event pool', '2009-11-05 15:39:34.361234', '2009-11-05 15:39:34.361234', NULL) RETURNING "id"
Factory.define :user do |u|
u.email 'user@example.com'
u.password 'somepassword'
u.password_confirmation 'somepassword'
# u.association :event_pool
end
# factory_girl creates associations first, thus user_id is NULL (thanks jferris via #thoughtbot IRC)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment