Rails Seed confusion
Posted
by
sscirrus
on Stack Overflow
See other posts from Stack Overflow
or by sscirrus
Published on 2010-12-31T13:04:52Z
Indexed on
2010/12/31
13:54 UTC
Read the original article
Hit count: 263
I'm having trouble seeding my database using seed.rb
, specifically where table relationships are concerned.
Here's a sample of the code:
# seed.rb
user = User.find_or_create_by_login(
:login => "myname",
:email => "[email protected]",
:user_type => "Admin",
:password => "admin",
:password_confirmation => "admin")
project = Project.find_or_create_by_user_id(
:user_id => user.id,
:name => "Test Project")
When project is created (along with other unrelated parameters I've left out from above), user_id is empty. How can I get this to work?
© Stack Overflow or respective owner