Class: Superconductor::FileController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/file_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/file_controller.rb', line 2

def edit
  respond_to do |format|
    format.json do
      if File.exists?('/'+params[:file])
        @file = File.open('/'+params[:file],'r')
        render json: { content: @file.read, writable: false && File.writable?(@file.path) }
      else
        render json: nil, status: :not_found
      end
    end
  end
end

#updateObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/file_controller.rb', line 15

def update
  @file = File.open('/'+params[:file],'w')
  @file.puts(params[:content])
  @file.close

  respond_to do |format|
    format.json { render json: nil, status: :ok }
  end
end