Class: Polyblock::Block
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Polyblock::Block
- Defined in:
- app/models/polyblock/block.rb
Class Method Summary collapse
Class Method Details
.export ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/models/polyblock/block.rb', line 21 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 |
.import(pbs) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/models/polyblock/block.rb', line 8 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 |