开发者

Loading sample data in Rails

W开发者_JS百科hen 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.


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.


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜