version_at does not accept timestamp #161

haggen opened this Issue Jun 14, 2012 · 3 comments


None yet

2 participants

haggen commented Jun 14, 2012

I came up with a little hack in my model to support timestamps in version_at method:

def version_at(timestamp)
  timestamp and super( or self

It worked for me. I though of forking/pull requesting but the repo seems abandoned.

batter commented Feb 28, 2013

The version_at method accepts a timestamp already, so I'm going to close this one. If you can be a little more clear as to what you were trying to accomplish here then we can revisit this, but this method is already defined, and I'm having trouble deciphering what you were attempting to accomplish here.

@batter batter closed this Feb 28, 2013
haggen commented Feb 28, 2013

Hi, it's been some time, I don't know if I can remember exactly what I was doing, but for one thing I am sure:

The method version_at was raising exception because my timestamp was a string and not integer. I thought it could be wise enough to forgive me with that.

But maybe it wasn't accepting the timestamp at all, like not even when I passed it with #to_i. I think it only worked when I tried to provide a DateTime object.

batter commented Feb 28, 2013

Thanks for the response. I am 100% sure that the version_at method will not raise an exception now if it receives a String, however, it seems that there may be some inconsistent behavior for how it behaves when it receives a DateTime vs. a DateTime.to_s. This is due to how ActiveRecord handles timestamps on a model (casting them to ActiveSupport::TimeWithZone when retrieving, which holds microseconds value whereas casting a Time or DateTime it to a String will drop that microseconds).

That being said, in most cases you should be safe to use a String representation of a time, unless you need a lot of preciseness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment