Class: DocumentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- DocumentsController
- Defined in:
- app/controllers/documents_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/documents_controller.rb', line 46 def create @document = Document.new(params[:document]) @document.save! redirect_to preview_document_path(@document) rescue ActiveRecord::RecordInvalid flash.now[:error] = "Error" render :action => 'new' end |
#destroy ⇒ Object
63 64 65 66 |
# File 'app/controllers/documents_controller.rb', line 63 def destroy @document.destroy redirect_to documents_path end |
#index ⇒ Object
38 39 40 |
# File 'app/controllers/documents_controller.rb', line 38 def index @documents = Document.all end |
#new ⇒ Object
42 43 44 |
# File 'app/controllers/documents_controller.rb', line 42 def new @document = Document.new end |
#preview ⇒ Object
33 34 35 36 |
# File 'app/controllers/documents_controller.rb', line 33 def preview # # otherwise looks for template for pdf, jpg or whatever # params[:format] = 'html' end |
#show ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/documents_controller.rb', line 8 def show if @document.document.path.blank? flash[:error] = "Does not contain a document" redirect_to preview_document_path(@document) elsif @document.document.exists? #puts "Document exists!" if @document.document.[:storage] == :filesystem # && # File.exists?(@document.document.path) # basically development or non-s3 setup send_file @document.document.path else #puts "Storage is S3?" # Privacy filters are still not active # basically a private s3 file # redirect_to @document.s3_url redirect_to @document.document.expiring_url end else flash[:error] = "Document does not exist at the expected location." redirect_to preview_document_path(@document) end end |
#update ⇒ Object
55 56 57 58 59 60 61 |
# File 'app/controllers/documents_controller.rb', line 55 def update @document.update_attributes!(params[:document]) redirect_to preview_document_path(@document) rescue ActiveRecord::RecordInvalid flash.now[:error] = "Error" render :action => 'edit' end |