I am using vestal version to try and compare two versions of the same model. In order to do this. I need to access the two instances of the model i am trying to compare. I have tried the following code:
@schedule = Schedule.last
@latest_version_model = @schedule.versions.last
@2nd_to_latest_version_of_model = @latest_version_model-1
I know this is wrong. @latest_version_model returns the number version, not the actual object. @ 2nd_to_latest_version_of_model returns an error. How do I access the latest version of the model instance and the 2nd latest version of the model instance?
The method
lastcould take an argument. If you calllast(2)you get the 2 latest elements, so doinglast(2).firstyou will get the second latest element.