Sha256: 99e246ea7136493ce6573d1aafd9907efb7a7d9ebc569341c71806d21203bd86

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

require 'json'

module Polyblock
  class Block < ActiveRecord::Base

    belongs_to :contentable, :polymorphic => true, :dependent => :destroy

    def self.import(pbs)
      pbs.each{|pb| Block.create!(pb) unless Block.where(:name => pb['name']).any? }
    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.import(#{output})"
      puts ""
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyblock-0.4.5 app/models/polyblock/block.rb