DBServer/app/controllers/upload_sorting_controller.rb
###################### Create a new document with pages
Create a new document with pages
Create a new document with pages
def create
    Document.transaction do
      begin
        @document = Document.new(params[:document])
        @document.save!
        params[:page].each_with_index do |page_id, position|
          p=Page.find(page_id)
          p.add_to_document(@document, position)
        end
        Log.write_status('ServerCreateDoc', "Created document with #{@document.reload.page_count} pages!")
      rescue
        Log.write_error('ServerCreateDoc', "ERROR creating document: #{@document.errors.full_messages }!")
        raise
      end
    end
    BackupWorker.perform_async(@document.id)
    render action: "new"
  end
def create Document . transaction do begin @document = Document . new ( params [ :document ] ) @document . save! params [ :page ] . each_with_index do | page_id , position | p = Page . find ( page_id ) p . add_to_document ( @document , position ) end Log . write_status ( 'ServerCreateDoc' , "Created document with #{@document.reload.page_count} pages!" ) rescue Log . write_error ( 'ServerCreateDoc' , "ERROR creating document: #{@document.errors.full_messages }!" ) raise end end BackupWorker . perform_async ( @document . id ) render action : "new" end
Create a new document with pages
Create a new document with pages
## backup new document to Amazon