Class: Alchemy::Admin::AttachmentsController
- Inherits:
-
ResourcesController
- Object
- ApplicationController
- BaseController
- BaseController
- ResourcesController
- Alchemy::Admin::AttachmentsController
- Includes:
- ArchiveOverlay, UploaderResponses
- Defined in:
- app/controllers/alchemy/admin/attachments_controller.rb
Constant Summary
Constants inherited from ResourcesController
ResourcesController::COMMON_SEARCH_FILTER_EXCLUDES
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #download ⇒ Object
- #index ⇒ Object
-
#show ⇒ Object
The resources controller renders the edit form as default for show actions.
- #update ⇒ Object
Methods included from ArchiveOverlay
Methods included from UploaderResponses
#failed_uploader_response, #successful_uploader_response
Methods inherited from ResourcesController
#edit, #new, #resource_filters, #resource_filters_for_select, #resource_handler, #resource_has_deprecated_filters, #resource_has_filters
Methods included from ResourcesHelper
#contains_relations?, #edit_resource_path, #new_resource_path, #render_attribute, #render_resources, #resource_attribute_field_options, #resource_has_tags, #resource_instance_variable, #resource_model, #resource_name, #resource_path, #resource_relations_names, #resource_scope, #resource_url_proxy, #resource_window_size, #resources_instance_variable, #resources_path, #sortable_resource_header_column
Methods inherited from BaseController
Methods included from Modules
included, #module_definition_for, register_module
Methods included from Alchemy::AbilityHelper
Methods included from ConfigurationMethods
#configuration, #multi_language?, #multi_site?, #prefix_locale?
Instance Method Details
#create ⇒ Object
42 43 44 45 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 42 def create @attachment = Attachment.create() handle_uploader_response(status: :created) end |
#destroy ⇒ Object
60 61 62 63 64 65 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 60 def destroy name = @attachment.name @attachment.destroy @url = (search_filter_params) flash[:notice] = Alchemy.t("File deleted successfully", name: name) end |
#download ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 67 def download @attachment = Attachment.find(params[:id]) send_file @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type } end |
#index ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 15 def index @query = Attachment.ransack(search_filter_params[:q]) @query.sorts = "name asc" if @query.sorts.empty? @attachments = @query.result if search_filter_params[:tagged_with].present? @attachments = @attachments.tagged_with(search_filter_params[:tagged_with]) end if search_filter_params[:filter].present? @attachments = apply_filters(@attachments) end @attachments = @attachments .page(params[:page] || 1) .per(items_per_page) if end end |
#show ⇒ Object
The resources controller renders the edit form as default for show actions.
38 39 40 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 38 def show render :show end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 47 def update @attachment.update() if ["file"].present? handle_uploader_response(status: :accepted) else render_errors_or_redirect( @attachment, (search_filter_params), Alchemy.t("File successfully updated") ) end end |