Sha256: 00dd64e9f244d264329e5825bc37ff4449c12a39544be9a668b30ef2b7bcc0ee
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
class UserExportFile < ActiveRecord::Base include Statesman::Adapters::ActiveRecordQueries include ExportFile enju_export_file_model if Setting.uploaded_file.storage == :s3 has_attached_file :user_export, storage: :s3, s3_credentials: Setting.amazon, s3_permissions: :private else has_attached_file :user_export, path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename" end validates_attachment_content_type :user_export, content_type: /\Atext\/plain\Z/ has_many :user_export_file_transitions def state_machine UserExportFileStateMachine.new(self, transition_class: UserExportFileTransition) end delegate :can_transition_to?, :transition_to!, :transition_to, :current_state, to: :state_machine def export! transition_to!(:started) tempfile = Tempfile.new(['user_export_file_', '.txt']) file = User.export(format: :txt) tempfile.puts(file) tempfile.close self.user_export = File.new(tempfile.path, 'r') if save send_message end transition_to!(:completed) rescue => e transition_to!(:failed) raise e end private def self.transition_class UserExportFileTransition end def self.initial_state :pending end end # == Schema Information # # Table name: user_export_files # # id :integer not null, primary key # user_id :integer # user_export_file_name :string(255) # user_export_content_type :string(255) # user_export_file_size :integer # user_export_updated_at :datetime # executed_at :datetime # created_at :datetime not null # updated_at :datetime not null #
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enju_leaf-1.1.0.rc17 | app/models/user_export_file.rb |