Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Latest commit

 

History

History
43 lines (30 loc) · 972 Bytes

README.md

File metadata and controls

43 lines (30 loc) · 972 Bytes

NOTE: THIS IS ALPHA CODE

who_dunit

This module wires Rails to store the user that created and last-updated an ActiveRecord model.

Usage

In your model

    class Model < ActiveRecord:Base
        who_dunit # Enable saving of created_by and updated_by
    end

In your base controller class (usually ApplicationController)

	class ApplicationController < ActiveController:Base
		who_dunit # Enable tracking of current user
	end

Migrations

## TODO Write migration example

Design

In ApplicationController:

  • around_filter stores the current user in current thread for the duration of the action ** current user stored in thread-local variable

In Model:

  • has_one association to user for 'created_by'
  • has_one association to user for 'updated_by'
  • before_create calback sets 'created_by' column
  • before_save callback sets 'updated_by' column

In Migrations: