Class: ErpInvoicing::ErpApp::Shared::FilesController
- Inherits:
-
ErpApp::Desktop::FileManager::BaseController
- Object
- ErpApp::Desktop::FileManager::BaseController
- ErpInvoicing::ErpApp::Shared::FilesController
- Defined in:
- app/controllers/erp_invoicing/erp_app/shared/files_controller.rb
Instance Method Summary collapse
Instance Method Details
#base_path ⇒ Object
7 8 9 |
# File 'app/controllers/erp_invoicing/erp_app/shared/files_controller.rb', line 7 def base_path @base_path = File.join(@file_support.root, Rails.application.config.erp_tech_svcs.file_assets_location, 'documents', @invoice.invoice_number) end |
#set_file_support ⇒ Object
36 37 38 |
# File 'app/controllers/erp_invoicing/erp_app/shared/files_controller.rb', line 36 def set_file_support @file_support = ErpTechSvcs::FileSupport::Base.new(:storage => Rails.application.config.erp_tech_svcs.file_storage) end |
#set_invoice ⇒ Object
32 33 34 |
# File 'app/controllers/erp_invoicing/erp_app/shared/files_controller.rb', line 32 def set_invoice @invoice = Invoice.find(params[:invoice_id]) end |
#upload_file ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/erp_invoicing/erp_app/shared/files_controller.rb', line 11 def upload_file clear_files result = {} upload_path = params[:directory] name = params[:name] data = request.raw_post begin @invoice.add_file(data, File.join(base_path, name)) result = {:success => true} rescue Exception=>ex Rails.logger.error ex. Rails.logger.error ex.backtrace.join("\n") result = {:success => false, :error => "Error uploading file."} end #the awesome uploader widget whats this to mime type text, leave it render :inline render :inline => result.to_json end |