Repository is archived
No commit activity in last 3 years
No release in over 3 years
ActiveRecord-Archiver is a simple tool for taking a subset of the records in one environment and exporting them for use in another environment. Design Constraints: - leave out ids so as not to create collisions in the new environment - preserve relations between records - Allow for cyclic relationships
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

activerecord-archiver

Import/Export specific ActiveRecord records as JSON, preserving relations

Example:

  # model definition
  class Node < ActiveRecord::Base
    # has attributes :name, and :next_id
    belongs_to :next, :class_name => 'Node'
  end
  
  # create a cycle of nodes
  nodes = [ Node.create(:name => 'a'),
            Node.create(:name => 'b'),
            Node.create(:name => 'c') ]
  nodes[0].update_attribute :next_id, nodes[1].id
  nodes[1].update_attribute :next_id, nodes[2].id
  nodes[2].update_attribute :next_id, nodes[0].id
  
  # export
  json = ActiveRecordArchiver.export(nodes)
  
  # json is '{"Node":[{"name":"a","next":1},{"name":"b","next":2},{"name":"c","next":0}]}'