github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

courtenay / acts_like_git forked from parfait/acts_like_git

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 160
    • 7
  • Source
  • Commits
  • Network (7)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A Rails plugin that uses git to version ActiveRecord fields, like acts_as_versioned, but a git. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Add a note about reloading 
courtenay (author)
Fri Jan 23 15:55:50 -0800 2009
commit  0d219eb10efc3c4e350479e1504ce977ff9a3753
tree    dc3e456d1849e1c6ac34de664d142e2c3ff5c960
parent  fee3be2612c084086c79227924df7b679b513143
acts_like_git /
name age
history
message
file .gitignore Fri Jan 23 13:38:17 -0800 2009 Use git less, use the database more [Jeremy McAnally]
file README Fri Jan 23 15:55:50 -0800 2009 Add a note about reloading [courtenay]
file Rakefile Fri Jan 23 13:38:17 -0800 2009 Use git less, use the database more [Jeremy McAnally]
directory generators/ Fri Jan 23 13:38:17 -0800 2009 Use git less, use the database more [Jeremy McAnally]
file init.rb Fri Jan 23 13:38:17 -0800 2009 Use git less, use the database more [Jeremy McAnally]
directory lib/ Fri Jan 23 13:42:17 -0800 2009 Merge branch 'master' of git@github.com:jeremym... [Jeremy McAnally]
directory rails/ Fri Jan 23 13:38:17 -0800 2009 Use git less, use the database more [Jeremy McAnally]
directory spec/ Fri Jan 23 13:38:17 -0800 2009 Use git less, use the database more [Jeremy McAnally]
README
= ActsLikeGit

ALG automagically saves the history of a given text or string field. It sits over the top of an ActiveRecord model; 
after a value is committed to the database, the plugin writes the new value to a text file and commits it to a git 
repository. This way you get all the advantages of using Git as version-control.

Note: this plugin does not play nice with other plugins which override the getters and setters on your model. So if, for 
example, you're creating a permalink on the same column as the versioning, you're going to run into problems due to the 
inherent complexity in define_attribute_methods.

== Usage

Declare which attributes are to be versioned:

  class Post < ActiveRecord::Base
    versioning(:title) do |version|
      version.repository = '/home/git/repositories/postal.git'
      version.message = lambda { |post| "Committed by #{post.author.name}" }
    end
  end

To view the complete list of changes:

  >> @post = Post.find 15
  <Post:15>
  >> @post.title
  => 'Freddy'
  >> @post.history(:title)
  => ['Joe', 'Frank', 'Freddy]
  >> @post.log
  => ['bfec2f69e270d2d02de4e8c7a4eb2bd0f132bdbb', '643deb45c12982dde75ba71657792a2dbdda83e6', 
  '1ce6c7368219db7698f4acc3417e656510b4138d']
  >> @post.revert_to '1ce6c7368219db7698f4acc3417e656510b4138d'
  >> @post.title
  => 'Joe'

Note that ActsLikeGit will store the current value of the field in your database, so you can use @post.title as before.  
If you want
to force git to reload the field's data, send true to the attribute like

    @post.title(true)


Copyright (c) 2008 [Jamie van Dyke, Courtenay Gasking, Scott Chacon, Roman Le Négrate], released under the MIT license.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server