Class: Droom::DocumentsController

Inherits:
EngineController show all
Defined in:
app/controllers/droom/documents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



41
42
43
44
45
# File 'app/controllers/droom/documents_controller.rb', line 41

def create
  @document.update_attributes(params[:document])
  @document.save!
  render :partial => 'created'
end

#destroyObject



57
58
59
60
# File 'app/controllers/droom/documents_controller.rb', line 57

def destroy
  @document.destroy
  head :ok
end

#editObject



47
48
49
# File 'app/controllers/droom/documents_controller.rb', line 47

def edit
  render 
end

#indexObject



13
14
15
16
17
# File 'app/controllers/droom/documents_controller.rb', line 13

def index
  respond_with @documents do |format|
    format.js { render :partial => 'droom/documents/documents' }
  end
end

#newObject



37
38
39
# File 'app/controllers/droom/documents_controller.rb', line 37

def new
  render 
end

#showObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/droom/documents_controller.rb', line 19

def show
  if @document.file
    # master documents are stored in private S3 buckets
    # To keep the documents secure, we: 
    # * publish them only through this controller (so no S3 links appear on the page)
    # * deliver them only to authenticated users
    # * delivery by redirecting to a URL that expires in ten minutes
    #
    # We could channel all file delivery through this controller and may do so in future but it
    # creates a nasty performance bottleneck. For now the redirect approach seems more robust 
    # and the expiring URLs sufficiently obscure.
    #
    redirect_to @document.file.expiring_url(Time.now + 600)
  else
    raise ActiveRecord::RecordNotFound
  end
end

#updateObject



51
52
53
54
55
# File 'app/controllers/droom/documents_controller.rb', line 51

def update
  @document.update_attributes(params[:document])
  @document.save!
  render :partial => 'listing', :object => @document.with_event
end