I have a table named “Grades” which contains 2 columns: “Name” and “Grade”.
I have already filled the Name field manually (I have about 150 records), and now I want to randomize a grade for each student.
I don’t want to use mysql syntax, I want to use ruby code.
Could you please tell me how to do it and where this script should be placed in the ruby direcory tree?
Later on I plan to replace the code that randomizes the grades with a more complicated code that calculates them (it’s just a temporary implnementation)…
(I’m new in Ruby and I want to do things correctly).
Make a rake task that loops through all the records and inserts a random number into the field. That way you can run it whenever you want.
http://railscasts.com/episodes/66-custom-rake-tasks