Class: Cms::AttachmentsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Cms::AttachmentsController
- Includes:
- Cms::Attachments::Serving, ContentRenderingSupport
- Defined in:
- app/controllers/cms/attachments_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#download ⇒ Object
This handles serving files for attachments that don’t have a user specified path.
-
#show ⇒ Object
Returns a specific version of an attachment.
Methods included from Cms::Attachments::Serving
#send_attachment, #send_attachments_with, send_attachments_with
Methods included from ContentRenderingSupport
#handle_access_denied_on_page, #handle_draft_not_found, #handle_not_found_on_page, #handle_server_error_on_page, #show_content_as_page
Methods inherited from BaseController
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/cms/attachments_controller.rb', line 26 def create = Attachment.new(permitted_params) .published = true if .save render :partial => 'cms/attachments/attachment_wrapper', :locals => {:attachment => } else #TODO: render html error string render :inline => 'an error ocurred' end end |
#destroy ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/cms/attachments_controller.rb', line 37 def destroy = Attachment.find(params[:id]) .destroy render :json => .id end |
#download ⇒ Object
This handles serving files for attachments that don’t have a user specified path. If a path is defined, the ContentController#try_to_stream will handle it.
Users can only download files if they have permission to view it.
21 22 23 24 |
# File 'app/controllers/cms/attachments_controller.rb', line 21 def download = Attachment.find(params[:id]) () end |
#show ⇒ Object
Returns a specific version of an attachment. Used to display older versions in the editor interface.
11 12 13 14 15 |
# File 'app/controllers/cms/attachments_controller.rb', line 11 def show = Attachment.unscoped.find(params[:id]) = .as_of_version(params[:version]) if params[:version] () end |