app/controllers/compiles_controller.rb
# GET /compiles/new
# GET /compiles/new.json
#
# Executes when user clicks the save button
# Saves code to disk and returns a UUID to the 
# browser. If the code is compilable it will also
# be compiled.


Executes when user clicks the save button
Saves code to disk and returns a UUID to the
browser. If the code is compilable it will also
be compiled.
Executes when user clicks the save button Saves code to disk and returns a UUID to the browser . If the code is compilable it will also be compiled .
def new
    @compile = Compile.new(params[:compile])
    stdin, stdout, stderr = compileAndSave()
    respond_to do |format|
      if @compile.save! and stderr.gets == nil
        format.json { render :json => @compile }
      else
        @compile[:error] = stderr
        @compile.save!
        format.json { render :json => @compile.to_json(:only => [:error, :uuid]), status => :ok }
      end
    end
  end
def new @compile = Compile . new ( params [ :compile ] ) stdin , stdout , stderr = compileAndSave ( ) respond_to do | format | if @compile . save! and stderr . gets == nil format . json { render :json => @compile } else @compile [ :error ] = stderr @compile . save! format . json { render :json => @compile . to_json ( :only => [ :error , :uuid ] ) , status => :ok } end end end
GET /compiles/new
GET /compiles/new.json
GET / compiles / new GET / compiles / new . json