Class: RailsEmbedEditor::EditorController
Instance Method Summary
collapse
#_authorize, #_authorize!
Instance Method Details
#edit ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/rails_embed_editor/editor_controller.rb', line 3
def edit
unless _authorize :edit, :local_file
render :json => {:success => false, :message => 'You dont have access to this file!'}
return
end
filename = params[:filename]
text = params[:content]
if filename.nil? or text.nil?
render :json => {:success => false, :params => params.to_json}
else
puts text.lines.map{|x| "#{x.chomp}\n"}.to_s
p text
manager = RailsEmbedEditor::FileManager.from_options(filename, params)
manager.save_text text
render :json => {:success => true}
end
end
|