Class: Biovision::Helpers::ExportHelper
- Inherits:
-
Object
- Object
- Biovision::Helpers::ExportHelper
- Defined in:
- app/lib/biovision/helpers/export_helper.rb
Overview
Helper for exporting model data
Constant Summary collapse
- EXPORT_DIR =
"#{Rails.root}/tmp/export"
- SPECIAL_FIELDS =
%w[id agent_id ip_address_id image attachment].freeze
Instance Method Summary collapse
Instance Method Details
#export_model(model) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/lib/biovision/helpers/export_helper.rb', line 11 def export_model(model) puts "Exporting model #{model}..." FileUtils.mkdir_p(EXPORT_DIR) unless Dir.exist?(EXPORT_DIR) file_name = "#{EXPORT_DIR}/#{model.table_name}.yml" File.open(file_name, 'wb') do |file| @file = file model.order(:id).each do |entity| @entity = entity export_entity end end end |