Giter VIP home page Giter VIP logo

acts_like_git's Introduction

= 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.

== 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'

Copyright (c) 2008 [Jamie van Dyke, Courtenay Gasking, Scott Chacon, Roman Le Négrate], released under the MIT license.

acts_like_git's People

Contributors

courtenay avatar hachiya avatar parfait avatar qrush avatar roman2k avatar schacon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.