mendicant-original / puzzlenode

Quiz application inspired by Project Euler and the Internet Problem Solving Contest (IPSC)
puzzlenode.com
81 stars 43 forks source link

db:seed #62

Closed gjp closed 12 years ago

gjp commented 12 years ago

amidoinitrite??

Actually, I'm making this up as I go along because I can't seem to find examples of how to structure non-trivial seeding tasks. I've tried, and found a lot of hard-coded one-liners and Ruby that reads like Perl. Heeeelp!

Advice on how to better organize this code would be much appreciated. Best practices for file layout, how to break up a 40-line Rake task (the submissions code is ugly) and where to put the pieces, basic stuff like that.

Cheers.

madebydna commented 12 years ago

You did a great job with the seed data task. I also couldn't find much in terms of best practices out there. In fact, it seems like the nature of generating seed data is inherently script-like and Perl-y :)

I like the PuzzleFaker module you created that abstract away the different "faking tasks". Just one thing, I noticed you use Kernel#rand with a range, which is a ruby 1.9.3 feature and will break on earlier versions of ruby. Not sure what the MU policy on this is.

I thought of looking at open source Rails apps for seed data inspiration. Diaspora was the first that jumped to mind, but maybe you have other ideas. Their seed data file uses Factories to generate some users and posts, so that might be a possibility too. I'm assuming that you should be able to use the PuzzleFaker helper methods within the factories.

All in all I think this should be ready to be merged in, but we need to first take care of the url slug stuff of @brentvatne, because slug will become a required field in puzzles. Also, before we merge it in we'll ask you to update the README with the seed data stuff.

jordanbyron commented 12 years ago

@gjp thanks for working on this. Here is your reward :balloon: :beer: :cake: :balloon:

gjp commented 12 years ago

Happy to help! I have dedicated one beer to this pull, though I'm fresh out of cake. Should we close #45?