Class: PresentationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PresentationsController
- Defined in:
- app/controllers/presentations_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #download ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #instructions ⇒ Object
- #new ⇒ Object
-
#show ⇒ Object
Defers serving files to nginx via the X-Accel-Redirect header.
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/presentations_controller.rb', line 17 def create @presentation = @project.presentations.new(presentation_params) if @presentation.save redirect_to project_presentations_path(@project) else render :action => :new end end |
#destroy ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/presentations_controller.rb', line 37 def destroy presentation && presentation.destroy flash[:notice] = l(:presentation_deleted_message) redirect_to project_presentations_path(@project) end |
#download ⇒ Object
64 65 66 67 68 69 |
# File 'app/controllers/presentations_controller.rb', line 64 def download send_file presentation.contents.path, :filename => presentation.contents_file_name, :type => presentation.contents.content_type, :streaming => true end |
#edit ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/presentations_controller.rb', line 43 def edit if presentation.blank? flash[:error] = "The requested presentation does not exist. Please verify the link or send the project owner a message." redirect_to(project_presentations_path(@project)) else @versions = @project.versions.open.push(presentation.version).compact.sort.uniq end end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/presentations_controller.rb', line 6 def index @presentations = @project.presentations end |
#instructions ⇒ Object
10 11 |
# File 'app/controllers/presentations_controller.rb', line 10 def instructions end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/presentations_controller.rb', line 13 def new @versions = @project.versions.open end |
#show ⇒ Object
Defers serving files to nginx via the X-Accel-Redirect header
28 29 30 31 32 33 34 35 |
# File 'app/controllers/presentations_controller.rb', line 28 def show if presentation.blank? flash[:error] = "The requested presentation does not exist. Please verify the link or send the project owner a message." redirect_to(project_presentations_path(@project)) end head :x_accel_redirect => presentation.x_accel_redirect_path_to(params[:static_asset_path]), :content_type => requested_content_type end |
#update ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/presentations_controller.rb', line 52 def update if presentation.blank? flash[:error] = "Hmmm....we couldn't find the presentation you were editing. Someone may have deleted it while you were performing your edits. You may want to send an email to the project owner to find out who has permissions to administer the project presentations." else presentation.title = presentation_params[:title] presentation.description = presentation_params[:description] presentation.save! end redirect_to project_presentations_path(@project) end |