Implement ActiveRecord state handling. AR is now functional.