Add token generation logic and hooks for ActiveRecord.