Fellow Overflowers,
I have a tab delimited csv file which contains dates in this format:
30-11-2011 2:24
I am parsing the csv with FasterSCV gem. I have created a migration which stores this info as datetime. Should I be doing that or define it as string and let Ruby convert it each time i retrieve it?
Do I need maybe to define some FasterCSV converters?
Thanks…
DateTime is a bit tricky. Is has a strict format
But you can do this
Now you have a DateTime object. But, pay attention to the time zone at the end of the parse method
When you fill the database use the seeds.rb file in your db folder.
I usually make a text file in the db folder, use my editor and replace all tabs with a “|” and make an array of each line
Lets say it looks like this (asuming it is a todo list)
todo file
seeds.rb file
then run
Make a some ruby magic!
I have not tested this code, but it might push you in the right direction