Class: RedactorRails::DocumentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/redactor_rails/documents_controller.rb', line 11

def create
  @document = RedactorRails.document_model.new

  file = params[:file]
  @document.data = RedactorRails::Http.normalize_param(file, request)
  if @document.respond_to?(RedactorRails.devise_user)
    @document.send("#{RedactorRails.devise_user}=", redactor_current_user)
    @document.assetable = redactor_current_user
  end

  if @document.save
    render :text => { :filelink => @document.url, :filename => @document.filename }.to_json
  else
    render :nothing => true
  end
end

#indexObject



6
7
8
9
# File 'app/controllers/redactor_rails/documents_controller.rb', line 6

def index
  @documents = RedactorRails.document_model.all
  render :json => @documents.to_json
end