Sha256: a72af32391e574d8d5903cb1b6ba294dcec00daceb496b1525d4a7bfe4c24859
Contents?: true
Size: 742 Bytes
Versions: 13
Compression:
Stored size: 742 Bytes
Contents
require 'json' module Polyblock class Block < ActiveRecord::Base belongs_to :contentable, :polymorphic => true, :dependent => :destroy def self.import(pbs) outputs = pbs.map do |pb| matches = Block.where :name => pb[:name] if matches.any? m = matches.first m.update_attributes(pb) if m.content != pb[:content] else Block.create(pb) end end outputs.include?(false) end def self.export output = Block.all.as_json(:except => [:id, :created_at, :updated_at]) puts "" puts "Run the following in Rails Console on the remote server:" puts "" puts "Polyblock::Block.import(#{output})" puts "" end end end
Version data entries
13 entries across 13 versions & 1 rubygems