David
David

Reputation: 4465

Loading sample data in Rails

When a user creates a new account on my site, I'd like to load sample data into his account. I would have done this easily with fixtures, but the problem is that the sample data needs to know the new account ID, so I need to pass this to the fixtures, but I don't know if it's possible.

That's my idea, but I am open to other best way to load sample data into DB for new account users.

Upvotes: 2

Views: 553

Answers (2)

Tobias
Tobias

Reputation: 4653

I'm not using Fixtures but I think it's really just for testing your application.

I haven't tested it yet but I would recommend you something like FactoryGirl. It's pretty straightforward to use and in combination with FFaker the best solution to generate sample data.

Hope this helps!

Happy coding :)

Upvotes: 0

David
David

Reputation: 4465

oh okay, i found the solution to my problem, xianese of http://xianese.blogspot.com/2008/05/use-yaml-to-load-sample-data-into.html have a solution.

Upvotes: 1

Related Questions