by Ole Friis Østergaard = Why do versioning? == Which problems do we solve? - The user regrets pressing that "Delete project" button - You want to track the changes to certain objects - You need to know who changed an object = Walk-through of Rails plug-ins - Rails makes it easy to be creative when doing plug-ins - Really simple pieces of code that do exiting stuff - Very non-intrusive - Easy to use == acts_as_logged - Makes a "shadow copy" of your normal database entries - Makes it easy to comply with laws concerning logging - Cannot show the history - Created by some of my colleages at Trifork - Not official homepage === How it works Add :history => true to create_table and drop_table statements in your migrations It will create a "shadow copy" of the table In the model: acts_as_logged statement Whenever a model object is saved, updated, or deleted, a new record is created in the table_name_history table == acts_as_versioned - Makes "shadow copies" of rows in the database - Makes it possible to view these old versions === What to do Annotate models with "acts_as_versioned" Don't access associations in the views Add a version column to the table to be versioned Add a new table called org_table_versioned Use the find_version method on models to access previous versions === Issues Associations does not work as expected when showing a previous version Adds an extra table to each of your tables === How does it work Returns OriginalClass::Version class for previous versions == acts_as_paranoid Calling destroy simply sets a "deleted_at" flag Therefore, deleted objects can still be found Not really a versioning plugin, but has a purpose Modifies finder and update methods to know about deleted methods Just add the deleted_at column to the table === Issues Not protected against updates, since it doesn't version You have to do a little to make it work with acts_as_versioned == acts_as_versioned_association Extends acts_as_versioned to support associations == Rails Undo Redo Undo/redo user actions === How to use it Controllers: Call "undoable_methods" in class definition Models: Annotate with "acts_as_undoable" Routes: - map.undo 'undo', :controller => 'projects', :action => :undo - map.redo 'redo', :controller => 'projects', :action => :redo Copy migration from plugin migration folder In the view: <%= undo_redo_links %> In controller actions: change("Update project #{@project.name}", projects_path, projects_path) do ... normal action code ... end == acts_subversive His own plugin: - Can go back in time - Can follow association == How it works In your migrations: - create_version_number_table (just once) - create_versioned_table and drop_versioned_table for each table In your models: - acts_subversive In your controllers: - use the find_version finder == Issues - has_and_belongs_to_many unsupported - Inheritance unsupported - (n+1) ew tables when versioning n classes =