Skip to content
ActiveRecord plugin for versioning your models. includes effective start and end dates and methods to make it easy to search on them
Ruby
Find file
Pull request Compare This branch is 9 commits ahead, 19 commits behind technoweenie:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
CHANGELOG
MIT-LICENSE
README
RUNNING_UNIT_TESTS
Rakefile
init.rb

README

This is a clone of the acts_as_versioned git project.  I am in the process of adding in temporal logic.  

It stores the effective_start and effective_end dates of records so that the version history can be searched for what happened at an exact point in history.  

Below is the details for acts_as_versioned which still works today.



= acts_as_temporal

This library adds simple versioning to an ActiveRecord module.  ActiveRecord is required.
as well as temporal capabilities

It will set timestamps for the effectivity of a record.

on initial create the versioned record

  the effective_start field will be set to current time or to whatever effective_date method is set to.
	the effective_end field will be set to max integer which is some time in the year 2038  (another y2k but waiting to happen)
	
on update the versioned record
	
	the previous version record's effective_end field will be set to the current time or to whatever effective_date method is set to.
	the new versioned record will act like the initial create
	

It turns all fields into integers for easier quering 

This can be converted by 
Time.at(1221627600)
and back with 
Time.now.to_i

version | effective_start | effective_end
1       | 1221627600      | 1222405201
2       | 1222405201      | 2147483202


so this allows you to write a between query on the version table to find what the state was at a point in time.

VersionedModel.find(:all, :conditions => ["effective_start <= ? AND effective_end > ?", point_in_time, point_in_time])


the model looks the same as acts_as_versioned except I added the following

  t.column effective_start, :integer
  t.column effective_end, :integer
  
  
== Resources

Install

* ./script/plugin install git://github.com/pbrumm/acts_as_temporal.git/

More details on approach

http://en.wikipedia.org/wiki/Temporal_database
Something went wrong with that request. Please try again.