The project is in a healthy, maintained state
Track and enforce user acceptance of Terms of Service, Privacy Policy, and other legal agreements with versioned documents and audit trails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

< 3
>= 7.1
 Project Readme

AgreementEngine

Versioned legal document management for Rails. Track and enforce user acceptance of Terms of Service, Privacy Policy, and other legal agreements with versioned documents and audit trails.

Installation

Add to your Gemfile:

gem "agreement_engine"

Then run:

bundle install
rails agreement_engine:install:migrations
rails db:migrate

Setup

1. Configure agreements

Create config/initializers/agreement_engine.rb:

AgreementEngine.configure do |config|
  config.agreements = [
    AgreementEngine::Agreement.new(
      id: :terms_of_service,
      title: "Terms Of Service",
      version_column: :accepted_terms_of_service_version_id,
      document_type: :terms_of_service,
      prompt_when_updated: true
    ),
    AgreementEngine::Agreement.new(
      id: :privacy_policy,
      title: "Privacy Policy",
      version_column: :accepted_privacy_policy_version_id,
      document_type: :privacy_policy,
      prompt_when_updated: true
    )
  ]
end

2. Include concerns

# app/models/user.rb
class User < ApplicationRecord
  include AgreementEngine::Signable
end

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  include AgreementEngine::Enforceable
end

3. Mount routes

# config/routes.rb
mount AgreementEngine::Engine, at: "/"

4. Seed initial documents

rails agreement_engine:seed

Auth Configuration

AgreementEngine defaults to Devise conventions. Override for other auth systems:

AgreementEngine.configure do |config|
  config.current_user_method = ->(c) { c.current_user }
  config.signed_in_method = ->(c) { c.user_signed_in? }
  config.auth_controller_method = ->(c) { c.devise_controller? }
  config.sign_out_method = ->(c) { c.sign_out(c.current_user) }
end

Routes

The engine provides:

  • GET /agreements/:id - Show agreement for acceptance
  • PATCH /agreements/:id - Accept agreement
  • DELETE /agreements/:id - Decline agreement (signs user out)
  • GET /terms - Public terms of service page
  • GET /privacy - Public privacy policy page
  • GET /admin/documents - Admin CRUD for managing document versions

Development

bundle install
bundle exec rake test