Tuesday, March 06, 2007

Dynamic fixtures for time didn't seem to be working...

For it while, it seemed like eRb wasn't working in Rail's dynamic fixtures. It use to work, and since I wasn't paying attention, at some point, something like this stopped working:
post:
id: 1
timestamp: <%= Time.now.to_s %>

After only a bit of head scratching and thinking (it pays to think!), I figured out that it only takes xmlschema datetime formats. I don't remember it being the case, but yeah, that's what you have to do now...at least for Rails 1.2.0+. So now, it should look like this.
post:
id: 1
timestamp: <%= Time.now.xmlschema %>

Hope that saved you some time. Tip!

No comments:

Post a Comment