views:

185

answers:

3

I'm creating test data for a Rails app. How do I define the value for a datetime field in YAML?

+1  A: 

when rails generates fixture files it uses the following format in the yaml files


one:
 something_at: 2010-02-11 11:02:57
 something_on: 2010-02-11

house9
+1  A: 

Found the answer here:

model:
   datetime_field: 2010-04-16 16:32:03 -5
Drew Johnson
+1  A: 

When I yaml DateTime, I generally pack it as a string:

foo = DateTime.now
foo_yaml = YAML.dump(foo.to_s)
foo = DateTime.parse(YAML.load(foo_yaml))
puts foo

I'd be interested to know if there's a better way.