Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'csv'
- desc "Import Students into Database"
- task :import_students => [:environment] do
- file="students_list.csv"
- CSV.foreach(file,:headers=>true) do |row|
- s=Student.new(:roll_no=>"#{row[0]}",
- :reg_no=>row[1],
- :name=>"#{row[2]}",
- :section=>"#{row[3]}",
- :semester=>row[4])
- s.save
- puts s.name
- puts s.roll_no
- puts s.semester
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement