Giter VIP home page Giter VIP logo

acts_as_archive's Introduction

ActsAsArchive
============

I'm working on an acts_as_archive plugin. If you think you could use this or a slight modification to this let me know. I will be using it to archive post data to help load on forums, but still have an easy way to find the archived data. 

this is still very much a beta plugin that i first started coding on July 10th.

This plugin requires the use of http://tangofoxtrot.com/2008/5/8/active-record-save-without-callbacks-plugin


currently to use it you would add 

acts_as_archive

to the model you want to have archive abilities.
Then add a migration file like this

class AddPostCommentArchiving < ActiveRecord::Migration
  def self.up
    transaction do
      Post.create_archive_table
      Comment.create_archive_table
      Article.create_archive_table
      Forum.create_archive_table
    end
  end

  def self.down
    
    transaction do
      Post.drop_archive_table
      Comment.drop_archive_table
      Article.drop_archive_table
      Forum.drop_archive_table
    end
  end
end




this plugin gives you 3 main methods

modelinstance.archive
Model.unarchive(id)
Model.find_archive(args)

find_archive:
  very similar to the regular find. Except it searches the model plus the archived data
  It accepts

  	:all	or	:first as the first value
  	:conditions (currently only 1 string; working on using the safe array format)
  	:order
  	:limit
  	:offset

  it also accepts id's


archive:
  removes the item with a delete call so callbacks aren't made. It also finds all associated models with a dependent destroy or dependent delete and archives them as well if the model is also set as acts as archive.

unarchive:
  adds the item back with it's original data id included. It also finds any associated models that are archived based on the primary key association.


TODO

make standard finds by ID search the archives as well, I may not include this in the plugin, but code separately.
allow for safe conditions in find using array format




Copyright (c) 2008 Kelly Mahan, released under the MIT license

acts_as_archive's People

Contributors

kellymahan avatar

Stargazers

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